How can I create my own form or page in an Inno setup based installer?

人盡茶涼 提交于 2020-01-02 02:37:07

问题


I am new in creating installers. I need to create a form with 3 textboxes:

  1. Domain
  2. User name
  3. User password

and then save them to the registry. I have already known how to save data to the registry.


回答1:


Inno has a flexible dialog/page engine which allows you to create custom pages in the wizard flow. See the CodeDlg.iss example included with the Inno install for a good example of how to do this.




回答2:


[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;


来源:https://stackoverflow.com/questions/8068544/how-can-i-create-my-own-form-or-page-in-an-inno-setup-based-installer

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!