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

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.


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

Tags:

Inno Setup