Inno Setup如何创建一个向导界面
以下为一个简单的rudio单选界面的代码
var
Page: TWizardPage;
RadioButton1, RadioButton2: TRadioButton;
Lbl1, Lbl2: TNewStaticText;
procedure CreatePage;
begin
Page := CreateCustomPage(wpInfoBefore, '向导页主标题', '向导页辅助标题');
RadioButton1 := TRadioButton.Create(Page);
RadioButton1.Left := ScaleX(100);
RadioButton1.Top := ScaleY(48);
RadioButton1.Width := Page.SurfaceWidth;
RadioButton1.Height := ScaleY(18);
RadioButton1.Caption := '选项一';
RadioButton1.Checked := True;
RadioButton1.Parent := Page.Surface;
RadioButton1.OnClick := @RadioButtonClick;
Lbl1 := TNewStaticText.Create(Page);
Lbl1.Left := ScaleX(115);
Lbl1.Top := ScaleY(68);
Lbl1.Width := ScaleX(250);
Lbl1.Height := ScaleY(50);
Lbl1.Caption := '选项一的具体信息';
Lbl1.Parent := Page.Surface;
RadioButton2 := TRadioButton.Create(Page);
RadioButton2.Left := ScaleX(100);
RadioButton2.Top := RadioButton1.Top + ScaleY(68);
RadioButton2.Width := Page.SurfaceWidth;
RadioButton2.Height := ScaleY(18);
RadioButton2.Caption := '选项二';
RadioButton2.Checked := false;
RadioButton2.Parent := Page.Surface;
RadioButton2.OnClick := @RadioButtonClick;
Lbl2 := TNewStaticText.Create(Page);
Lbl2.Left := ScaleX(115);
Lbl2.Top := Lbl1.Top + ScaleY(68);
Lbl2.Width := ScaleX(250);
Lbl2.Height := ScaleY(50);
Lbl2.Caption := '选项二的具体信息';
Lbl2.Parent := Page.Surface;
end;
procedure InitializeWizard();
begin
CreatePage;
end;
创建这个向导界面有以下几个关键点
1. 声明一个名称为Page的页面
var
Page: TWizardPage;
2. 声明创建页面的程序,在进程中创建页面
procedure CreatePage;
3. 创建页面并赋值给Page
Page := CreateCustomPage(wpWelcome, ‘向导页主标题’, ‘向导页辅助标题’);
其它的都是页面元素的具体声明与描述,这个需要根据个人需要定制。
4. CreateCustomPage(const AfterID: Integer; const ACaption, ADescription: String): TwizardPage
CreateCustomPage函数为创建一个自定义的页面,第一个参数为页面ID,表示我们的页面要在这个ID的页面之后出现,系统里面有一些预订的页面ID,wpWelcome,wpLicense,wpPassword,wpInfoBefore,wpUserInfo,wpSelectDir,wpSelectComponents,wpSelectProgramGroup,wpSelectTasks,wpReady,wpPreparing,wpInstalling,wpInfoAfter,wpFinished,根据自己需求放置我们的页面。
5. 创建页面程序写完后一定要放入初始化向导页程序中,InitializeWizard为系统进程,用于在开始的时候改变向导或向导页,我们创建页面的进程需要放入里面执行。
procedure InitializeWizard();
begin
CreatePage;
end;