Inno Setup entry (16) -- Inno Setup class reference (2)

Source: Internet
Author: User

Next we will introduce how to add buttons on the custom page. Button belongsTbuttonClass, which inherits fromTbuttoncontrolThe class is defined as follows:

Tbutton = Class (tbuttoncontrol)

Property cancel: Boolean; read write;

Property caption: string; read write;

Property default: Boolean; read write;

Property Font: tfont; read write;

Property modalresult: longint; read write;

Property onclick: tpolicyevent; read write;

End;

Its Inheritance relationships include:

 

Next, we will add a button on a created custom page:

[Setup]

Appname = test

Appvername = test

Defaultdirname = "E: \ test"

Appversion = 1.0

[Files]

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

[Code]

VaR

Mypage: twizardpage;

Mybtn: tbutton;

Procedure initializewizard ();

Begin

Mypage: = createcustompage (wpwelcome ,'Title: Custom page','Description: This is my custom page.');

Mybtn: = tbutton. Create (NiL );

Mybtn. Parent: = mypage. surface;

End;

First, explain this section.Code.

First Mybtn: = tbutton. Create (NiL ); Statement. Tbutton Class member functions Create , Create an instantiated Tbutton Object, which is used here Mybtn Get this object, parameter Nil The statement is null. Mybtn: = tbutton. Create (mypage ); Generally, you do not need to consider the differences between the two statements. The parameter of the function determines who will release the created control, Nil ,ProgramThis button is not released when the form is closed or the form is closed. Nil You need to manually release a page. If it is set to a page, the page is automatically released when it is released.

The other one isMybtnOfParentProperty inherited fromTwincontrolClass. This attribute specifies the container that contains this component. The button can only be displayed and moved in the specified package container.

When the installer is running on the custom page, the following window appears:

 

At this time, the button does not have a title, and the clicking does not respond, because the above Code does not add corresponding properties and events for it.

The following code will improve the above example (only modifiedCodeSegment ):

[Code]

VaR

Mypage: twizardpage;

Mybtn: tbutton;

Myfont: tfont;

Procedure clickmybtn (Sender: tobject );

Begin

Msgbox ('You clicked the button~~ ', Mbinformation, mb_ OK );

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. Default: = true;

Myfont: = tfont. Create ();

Myfont. Size: = 16;

Myfont. Style: = [fsbold];

Myfont. Style: = myfont. Style + [fsitalic];

(*Or use

Myfont. Style: = [fsbold, fsitalic];

*)

Mybtn. Font: = myfont;

Mybtn. Width: = 300;

Mybtn. Height := 100;

Mybtn. onclick: = @ clickmybtn;

End;

A newTfontInstanceMyfontThis object mainly sets attributes such as the size, color, and bold of characters displayed on the object.CaptionSet the text displayed in the button,DefaultProperty indicates that this button is selected by default, followed by the property of the displayed text, and the lastWidthAndHeightSet the button size. These two attributes are inherited fromTcontrolFinally, the event response function of the button. When you click the button, runClickmybtnThis process is also implemented in the front. Note that the implemented code must be placed before calling this process; otherwise, compilation fails. The running effect is as follows:

In addition, buttons have some attributes, suchTop,LeftIs the control button location, you can test it.

 

 

From: http://www.360doc.com/content/13/0327/14/4221543_274242269.shtml

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.