Inno SetupScripts support many classes, which enable installationProgramThrough the use of these classes, many amazing installation programs will be created. The following describes how to learn classes.
Create custom Wizard Page
The custom wizard page must be in Initializewizard Create an event function by using Createcustompage Function to create an empty page, or use Createinput... page And Createoutput... page And other functions to create pre-built pages, such Createinputdirpage , Createinputfilepage , Createoutputprogresspage And other functions. After the page is created, you can add controls on the page. You can manually create controls or use special functions on the pre-created page. Most Create... page The first parameter of the function is usually Page ID This parameter specifies the existing page to which the newly created page is placed. There are several ways to obtain an existing page Page ID For example, a page created by a user has a property ID Is a read-only integer, and its value is ID , The built-in Wizard Page has a reservation ID , The available names are as follows:
wpwelcome |
wplicense |
wppassword |
wpinfobefore |
wpuserinfo |
wpselectdir |
wpselectcomponents |
wpselectprogramgroup |
wpselecttasks |
wpready |
wppreparing |
wpinstalling |
Wpinfoafter |
Wpfinished |
|
|
After the custom page is created, the installer will display the page and process it like the pre-created page, for example, calling all pages associatedNextbuttonclickAndShouldskippageEvent functions.
CreatecustompageThe function prototype is as follows:
Function createcustompage (const afterid: integer; const acaption, adetion: string): twizardpage
The first parameter and the previousPage IDYes, you can use any of the above tables as the parameter, the second parameterAcaptionSpecify the page title. The title is displayed at the top of the page, and the third parameter is the description of the page. The return value of a function isTwizardpageClass. According to the help document of Inno Setup, the prototype of this class is as follows:
Twizardpage = Class (tcomponent)
Property ID: integer; read;
Property caption: string; read write;
Property Description: string; read write;
Property Surface: tnewnotebookpage; read write;
Property surfaceheight: integer; read write;
Property surfacewidth: integer; read write;
Property onactivate: twizardpagenotifyevent; read write;
Property onbackbuttonclick: twizardpagebuttonevent; read write;
Property oncancelbuttonclick: twizardpagecancelevent; read write;
Property onnextbuttonclick: twizardpagebuttonevent; read write;
Property onshouldskippage: twizardpageshouldskipevent; read write;
End;
Twizardpagenotifyevent = procedure (Sender: twizardpage );
Twizardpagebuttonevent = function (Sender: twizardpage): Boolean;
Twizardpagecancelevent = procedure (Sender: twizardpage; var acancel, aconfirm: Boolean );
Twizardpageshouldskipevent = function (Sender: twizardpage): Boolean;
The following program will create a simple custom page and display it behind the welcome page:
[Setup] Appname = test Appvername = test Defaultdirname = "E: \ test" Appversion = 1.0 [Files] Source: "F: \ Desktop \ test \ ipmsg.exe"; flags: dontcopy [Code] Procedure initializewizard (); Begin Createcustompage (wpwelcome ,'Title: Custom page','Description: This is my custom page.'); End; |
After runningWelcomePage ClickNextThe following page appears:
In addition, let's test it.CreatecustompageReturn ValueTwizardpageClass attributes. For example, the following example will testIDAttributes andNextbuttonclickAttribute:
[Code] VaR Mypage: twizardpage; Mypageid: integer; Function nextbuttonclick (curpageid: integer): Boolean; Begin If curpageid = mypageid then Begin If msgbox ('Are you sure you want to leave this page?', Mbconfirmation, mb_yesno or mb_defbutton2) = idyes then result: = true; End Else Result: = true; End; Procedure initializewizard (); Begin Mypage: = createcustompage (wpwelcome ,'Title: Custom page','Description: This is my custom page.'); Mypageid: = mypage. ID; End; |
Run the program. When the custom page is reached, clickNextThe following confirmation dialog box appears:
Select "yes" to go to the next page. "No" will be left on this page.
Although the above page does not have any space, it is not easy to add various controls to the page after the page is successfully created. It is like after the foundation is completed, it is much easier to build a house.
From: http://www.360doc.com/content/13/0327/14/4221543_274242607.shtml