Delphi inputbox,inputquery Usage

Source: Internet
Author: User

Delphi:inputquery,inputbox Usage and differences

function Inputquery (const acaption, aprompt:string; var value:string): Boolean;
The Inputquery return value is the string in which the OK input is placed in the variable value

function InputBox (const acaption, aprompt, adefault:string): string;
The InputBox return value is a string, that is, the input string

Procedure Tform1.button1click (Sender:tobject);
Var
s:string;
Begin
When the OK button is clicked, the
If Inputquery (' title ', ' hint character ', 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 ', ' hint character ', s);
If S<> ' Then
ShowMessage (s);
End

Delphi customizes the InputBox by customizing the message, enabling it to support the mask and modify the button's caption

First, customize a message ID

Const
Inputboxmessage = Wm_user + 200;

The process of declaring and implementing the message is then

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: = FindWindowEx (hinputform, 0, ' Tedit ', nil);
SendMessage (Hedit, Em_setpasswordchar, Ord (' * '), 0);
Change button text:
Hbutton: = FindWindowEx (hinputform, 0, ' TButton ', ' Cancel ');
SendMessage (Hbutton, wm_settext,0, Integer (PChar (' Cancel ')));
Hbutton: = FindWindowEx (hinputform, 0, ' TButton ', ' OK ');
SendMessage (Hbutton, wm_settext,0, Integer (PChar (' OK ')));
End
End

Using a custom InputBox

PostMessage (Handle, inputboxmessage, 0, 0);
InputBox (' Please set unlock password ', ' please set unlock password (cannot be empty): ', ');

Delphi inputbox,inputquery Usage

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.