This article Reprinted from: http://blog.csdn.net/yushanddddfenghailin/article/details/17251019
Radio button
Single-choice buttons are also common during installation. For example, you can choose to install different functions for the same program, such as 32-bit or 64-bit. The two are exclusive, therefore, you can use the single-choice button (radiobutton). The single-choice button placed in the same container is automatically exclusive. The definition of the single-choice button in the Pascal script is as follows:
Tradiobutton = Class (tbuttoncontrol)
Property alignment: talignment; read write;
Property caption: string; read write;
Property checked: Boolean; read write;
Property color: tcolor; read write;
Property Font: tfont; read write;
Property onclick: tpolicyevent; read write;
Property ondblclick: tpolicyevent; read write;
End;
Its Inheritance relationships include:
The hierarchical model of the visible and button is the same. In fact, radiobutton and button are not much different. The only difference is that single-choice buttons are exclusive.
The following code adds a text box and two radio buttons on the custom Wizard Page:
[Setup] Appname = test Appvername = test Defaultdirname = "E: \ test" Appversion = 1.0 [Files] Source: "F: \ Desktop \ Inno \ ipmsg.exe"; flags: dontcopy [Code] VaR Mypage: twizardpage; Radio1, Radio2: tradiobutton; LBL: tlabel; Font: tfont; {Radio1 Event Response Process} Procedure clickradio1 (Sender: tobject ); Begin LBL. Font. Color: = clred; End; {Radio2 Event Response Process} Procedure clickradio2 (Sender: tobject ); Begin LBL. Font. Color: = clblue; End; Procedure initializewizard (); Begin Mypage: = createcustompage (wpwelcome, 'title: Custom page', 'description: This is my custom page '); LBL: = tlabel. Create (mypage ); LBL. Parent: = mypage. surface; LBL. Caption: = 'change the option of the radio button, and I will change the color '; Radio1: = tradiobutton. Create (mypage ); Radio1.parent: = mypage. surface; Radio1.caption: = 'red '; Radio1.top: = LBL. Top + 20; Font: = tfont. Create (); Font. Color: = clred; Radio1.font: = font; Radio1.onclick: [email protected]; Radio2: = tradiobutton. Create (mypage ); Radio2.parent: = mypage. surface; Radio2.caption: = 'Blue '; Radio2.top: = radio1.top + 20; Font. Color: = clblue; Radio2.font: = font; Radio2.onclick: [email protected]; End; |
In this section of the Code, the emphasis is on the onclick event of the single-choice button. The process that this attribute points to determines the action after the single-choice button is clicked. After the installation file runs on the custom page, the effect is as follows:
Some may ask how to make a choice among multiple sets of different options? For example, how does one select a color and the font size? For this problem, traditionally, Delphi is implemented by adding the control class tgroupbox, but this class is not supported in Pascal scripts, so the method in Delphi is not feasible. Although the traditional method does not work, it does not mean that Inno is powerless. The simplest method is to create two pages, one page processing option, another page processing option is another option (so it is not very good to use the previous example here, mainly used to describe the use of single-choice buttons). After all the users have selected the option, they will execute it in a unified manner. Another method is to use other controls, such as ListBox ).