如何在基于Inno设置的安装程序中创建自己的表单或页面?

时间:2011-11-09 16:55:46

标签: inno-setup

我是创建安装程序的新手。我需要创建一个包含3个文本框的表单:

  1. 用户名
  2. 用户密码
  3. 然后将它们保存到注册表中。我已经知道如何将数据保存到注册表中。

2 个答案:

答案 0 :(得分:9)

Inno有一个灵活的对话框/页面引擎,允许您在向导流程中创建自定义页面。有关如何执行此操作的一个很好的示例,请参阅Inno安装中包含的CodeDlg.iss example

答案 1 :(得分:7)

[Code]
var
lblDomain: TLabel;
lblUserName: TLabel;
lblPassword: TLabel;
txtDomain: TEdit;
txtUserName: TEdit;
txtUserPassword: TPasswordEdit;

procedure frmDomainReg_Activate(Page: TWizardPage);
begin
end;

function frmDomainReg_ShouldSkipPage(Page: TWizardPage): Boolean;
begin
Result := False;
end;

function frmDomainReg_BackButtonClick(Page: TWizardPage): Boolean;
begin
Result := True;
end;

function frmDomainReg_NextButtonClick(Page: TWizardPage): Boolean;
begin
Result := True;
end;

procedure frmDomainReg_CancelButtonClick(Page: TWizardPage; var Cancel, Confirm: Boolean);
begin
end;

function frmDomainReg_CreatePage(PreviousPageId: Integer): Integer;
var
Page: TWizardPage;
begin
Page := CreateCustomPage(
PreviousPageId,
'Domain Registration',
'Enter Domain Registration Data'
);

{ lblDomain }
lblDomain := TLabel.Create(Page);
with lblDomain do
begin
Parent := Page.Surface;
Left := ScaleX(24);
Top := ScaleY(24);
Width := ScaleX(35);
Height := ScaleY(13);
Caption := 'Domain';
end;

{ lblUserName }
lblUserName := TLabel.Create(Page);
with lblUserName do
begin
Parent := Page.Surface;
Left := ScaleX(24);
Top := ScaleY(56);
Width := ScaleX(52);
Height := ScaleY(13);
Caption := 'User Name';
end;

{ lblPassword }
lblPassword := TLabel.Create(Page);
with lblPassword do
begin
Parent := Page.Surface;
Left := ScaleX(24);
Top := ScaleY(88);
Width := ScaleX(46);
Height := ScaleY(13);
Caption := 'Password';
end;

{ txtDomain }
txtDomain := TEdit.Create(Page);
with txtDomain do
begin
Parent := Page.Surface;
Left := ScaleX(120);
Top := ScaleY(16);
Width := ScaleX(185);
Height := ScaleY(21);
TabOrder := 0;
end;

{ txtUserName }
txtUserName := TEdit.Create(Page);
with txtUserName do
begin
Parent := Page.Surface;
Left := ScaleX(120);
Top := ScaleY(48);
Width := ScaleX(185);
Height := ScaleY(21);
TabOrder := 1;
end;

{ txtUserPassword }
txtUserPassword := TPasswordEdit.Create(Page);
with txtUserPassword do
begin
Parent := Page.Surface;
Left := ScaleX(120);
Top := ScaleY(80);
Width := ScaleX(185);
Height := ScaleY(21);
TabOrder := 2;
end;


with Page do
begin
OnActivate := @frmDomainReg_Activate;
OnShouldSkipPage := @frmDomainReg_ShouldSkipPage;
OnBackButtonClick := @frmDomainReg_BackButtonClick;
OnNextButtonClick := @frmDomainReg_NextButtonClick;
OnCancelButtonClick := @frmDomainReg_CancelButtonClick;
end;

Result := Page.ID;
end;

procedure InitializeWizard();
begin
{this page will come after welcome page}
frmDomainReg_CreatePage(wpWelcome);
end;