(Transfer) Inno Setup entry (18) -- Inno Setup class reference (4)

Source: Internet
Author: User
This article is reproduced in the edit box at http://blog.csdn.net/yushanddddfenghailin/article/details/17251009.

An editing box is also called a text box. It is a typical window visualization component that can be used to input or display text. It is one of the most common components in programming, you can obtain a lot of user input information. The edit box in Pascal is implemented by the tedit class, which is defined as follows:

Tedit = Class (tcustomedit)

Property Autoselect: Boolean; read write;

Property autosize: Boolean; read write;

Property borderstyle: tborderstyle; read write;

Property charcase: teditcharcase; read write;

Property color: tcolor; read write;

Property Font: tfont; read write;

Property hideselection: Boolean; read write;

Property maxlength: integer; read write;

Property passwordchar: Char; read write;

Property readonly: Boolean; read write;

Property text: string; read write;

Property onchange: tpolicyevent; read write;

Property onclick: tpolicyevent; read write;

Property ondblclick: tpolicyevent; read write;

Property onkeydown: tkeyevent; read write;

Property onkeypress: tkeypressevent; read write;

Property onkeyup: tkeyevent; read write;

End;

The hierarchical model of this class is as follows:

The following code demonstrates creating an editing box and the text attribute of the editing box:

[Setup]

Appname = test

Appvername = test

Defaultdirname = "E: \ test"

Appversion = 1.0

[Files]

Source: "F: \ Desktop \ Inno \ ipmsg.exe"; flags: dontcopy

[Code]

VaR

Mypage: twizardpage;

Mybtn: tbutton;

ED1, ED2, ed3: tedit;

Procedure clickmybtn (Sender: tobject );

Begin

Ed3.text: = ed1.text + ''+ ed2.text;

End;

Procedure initializewizard ();

Begin

Mypage: = createcustompage (wpwelcome, 'title: Custom page', 'description: This is my custom page ');

Mybtn: = tbutton. Create (mypage );

Mybtn. Parent: = mypage. surface;

Mybtn. Caption: = 'click me ~ ';

Mybtn. onclick: [email protected];

ED1: = tedit. Create (mypage );

Ed1.parent: = mypage. surface;

Ed1.top: = mybtn. Top + 30;

Ed1.width: = mybtn. width;

ED2: = tedit. Create (mypage );

Ed2.parent: = mypage. surface;

Ed2.top: = ed1.top + 30;

Ed2.width: = mybtn. width;

Ed3: = tedit. Create (mypage );

Ed3.parent: = mypage. surface;

Ed3.top: = ed2.top + 30;

Ed3.width: = mybtn. width;

End;

Attribute text is used to set or obtain the content in the text box. Whether set or obtained, the parameter must be of the string type. The running effect is as follows:

If you want to implement the algebraic operation of two numbers, rather than the concatenation of strings, The onclick process of the button should be modified as follows:

Procedure clickmybtn (Sender: tobject );

VaR

A, B: extended;

Begin

A: = strtofloat (ed1.text );

B: = strtofloat (ed2.text );

Ed3.text: = floattostr (A + B );

End;

Strtofloat and floattostr implement conversion from string to real number and from real number to string respectively. Enter a value in the first and second text boxes, and click the button to set the content in the third text box to the two-digit sum. Next we will talk about other attributes. Modify the code segment as follows:

[Code]

VaR

Mypage: twizardpage;

Mybtn: tbutton;

ED1, ED2, ed3: tedit;

A, B, C: string;

Procedure clickmybtn (Sender: tobject );

Begin

A: = ed1.text;

B: = ed2.text;

C: = A + B;

Ed3.text: = C;

End;

Procedure initializewizard ();

Begin

Mypage: = createcustompage (wpwelcome, 'title: Custom page', 'description: This is my custom page ');

Mybtn: = tbutton. Create (mypage );

Mybtn. Parent: = mypage. surface;

Mybtn. Caption: = 'click me ~ ';

Mybtn. onclick: [email protected];

ED1: = tedit. Create (mypage );

Ed1.parent: = mypage. surface;

Ed1.top: = mybtn. Top + 30;

Ed1.width: = mybtn. width;

Ed1.charcase: = ecuppercase; {upper case}

Ed1.showhint: = true;

Ed1.hint: = 'uppercase letters ';

ED2: = tedit. Create (mypage );

Ed2.parent: = mypage. surface;

Ed2.top: = ed1.top + 30;

Ed2.width: = mybtn. width;

Ed2.passwordchar: = '#'; {password style}

Ed3: = tedit. Create (mypage );

Ed3.parent: = mypage. surface;

Ed3.top: = ed2.top + 30;

Ed3.width: = mybtn. Width * 2;

Ed3.readonly: = true; {read-only}

End;

The preceding four attributes are described: charcase sets the text display format, which can have three values: (ecnormal, ecuppercase, and eclowercase) Normal Mode, upper case mode, and lower case mode; the passwordchar attribute replaces the input text with the specified style. The readonly attribute makes the text box unacceptable. the hint and showhint attributes are used when the user's mouse stays on the text box, the prompt text is displayed. Note that the prompt text is displayed only when the showhint is set to true.

In addition, the edit box can also correspond to some events, such as clicking, double-clicking, and changing the text content. The implementation is not bad than the button, so it is no longer awkward here. The following describes the attributes of the three buttons: onkeydown, onkeypress, and onkeyup.

The three attributes are called when the user cursor stays in the text box and the user presses a key on the keyboard. The test code is as follows:

[Code]

VaR

Mypage: twizardpage;

ED: tedit;

Procedure editkeydown (Sender: tobject; var key: word; shift: tshiftstate );

Begin

If (Key = 67) and (shift = [ssalt]) then

Msgbox ('you have pressed Alt + C', mbinformation, mb_ OK );

End;

Procedure initializewizard ();

Begin

Mypage: = createcustompage (wpwelcome, 'title: Custom page', 'description: This is my custom page ');

ED: = tedit. Create (mypage );

Ed. Parent: = mypage. surface;

Ed. onkeydown: [email protected];

End;

When you press the Alt + C combination in the edit box, a message box is displayed, which allows you to make corresponding actions for the key combinations that we are interested in, for example, if you want to disable the paste function, modify the Code as follows:

Procedure editkeydown (Sender: tobject; var key: word; shift: tshiftstate );

Begin

If (Key = 86) and (shift = [ssctrl]) then

Msgbox ('paste invalid, please enter manually ', mbinformation, mb_ OK );

Ed. Text: = '';

End;

However, it should be noted that right-click and paste cannot be blocked, but Ctrl + V is blocked. The other two key attributes are similar to the keydown described here. You can test them against each other.

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.