Delphi inputbox and inputquery usage

Source: Internet
Author: User
Delphi: inputquery, inputbox usage and Difference

Function inputquery (const acaption, aprompt: string; VaR value: string): Boolean;
The return value of inputquery is whether the string entered with OK is placed in the variable value.

Function inputbox (const acaption, aprompt, adefault: string): string;
The return value of inputbox is a string, that is, the input string.

Procedure tform1.button1click (Sender: tobject );
VaR
S: string;
Begin
// After clicking the OK button
If inputquery ('title', 'character prompting ', S) then
Begin
If S <> ''then // If the input is not empty
Showmessage (s );
End;

 

End;

Procedure tform1.button2click (Sender: tobject );
VaR
S: string;
Begin
S: = inputbox ('title', 'character prompting ', S );
If S <> ''then
Showmessage (s );
End;

Delphi uses a custom message to customize the inputbox to enable it to support the mask and modify the caption of the button

First, define a Message ID.

Const
Inputboxmessage = wm_user+ 200;

Then declare and implement the message processing process.

Procedure inputboxsetpasswordchar (var msg: tmessage); message inputboxmessage; // Declaration

Procedure tfrm. inputboxsetpasswordchar (var msg: tmessage); // implementation
VaR
Hinputform, hedit, hbutton: hwnd;
Begin
Hinputform: = screen. Forms [0]. Handle;
If (hinputform <> 0) then
Begin
Hedit: = finddomainwex (hinputform, 0, 'tedit ', nil );
Sendmessage (hedit, em_setpasswordchar, ord ('*'), 0 );
// Change button text:
Hbutton: = find1_wex (hinputform, 0, 'tbutton', 'cancel ');
Sendmessage (hbutton, wm_settext, 0, INTEGER (pchar ('cancel ')));
Hbutton: = find1_wex (hinputform, 0, 'tbutton', 'OK ');
Sendmessage (hbutton, wm_settext, 0, INTEGER (pchar ('OK ')));
End;
End;

 

Use the custom inputbox

postmessage (handle, inputboxmessage, 0, 0);
inputbox ('set the unlock password', 'set the unlock password (cannot be blank ):', '');

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.