Inno Setup:创建自定义表单

丹尼尔·J。

我正在使用Inno Setup。我是一个初学者,对此不太熟悉。我的标准安装程序中有两个页面,一个页面一个页面RepositoryPage另一个页面,我需要使用其元素(ServicePage(最后一页))。

资料库页面:

在此处输入图片说明

procedure CreateRepositoryPage;
var
    i : Integer;
    SqlNamesArray: TArrayOfString;
    LblMonitorService, LblUsername, LblPassword : TNewStaticText;
begin

    RepositoryPage := CreateInputQueryPage(wpSelectComponents, 'Configuration', '' , '');

    { Windows username. RepositoryPage.Edits[2] }
    RepositoryPage.Add('', False);
    { Windows password. RepositoryPage.Edits[3] }
    RepositoryPage.Add('', True);

    LblMonitorService := TNewStaticText.Create(RepositoryPage);
    with LblMonitorService do
    begin
        Parent := RepositoryPage.Surface;
        Left := 0;
        Width := RepositoryPage.SurfaceWidth;
        Height := ScaleY(17);
        AutoSize := False;
        Caption := 'Dashboard service';
    end;

    LblUsername := TNewStaticText.Create(RepositoryPage);
    with LblUsername do
    begin
        Parent := RepositoryPage.Surface;
        Left := 0;
        Top := LblMonitorService.Top + LblMonitorService.Height + ScaleY(17);
        Width := RepositoryPage.SurfaceWidth;
        Height := ScaleY(17);
        AutoSize := False;
        Caption := 'Windows account username (Domain\Username):';
    end;

    RepositoryPage.Edits[0].Top := LblUsername.Top + LblUsername.Height;

    LblPassword := TNewStaticText.Create(RepositoryPage);
    with LblPassword do
    begin
        Parent := RepositoryPage.Surface;
        Left := 0;
        Top := RepositoryPage.Edits[0].Top + RepositoryPage.Edits[0].Height + ScaleY(15);
        Width := RepositoryPage.SurfaceWidth;
        Height := ScaleY(17);
        AutoSize := False;
        Caption := 'Windows account password:';
    end;

    RepositoryPage.Edits[1].Top := LblPassword.Top + LblPassword.Height;


    LogOnAsServiceCheckBox := TNewCheckBox.Create(RepositoryPage);
    with LogOnAsServiceCheckBox do
    begin
        Parent := RepositoryPage.Surface;
        Top := RepositoryPage.Edits[1].Top + RepositoryPage.Edits[1].Height + ScaleY(16);
        Left := 0;
        Width := RepositoryPage.SurfaceWidth;
        Height := ScaleY(17);
        Caption := 'Add "Log on as a service" permission';
        Checked := True;
    end;


    RepositoryPage.Values[0] := ExpandConstant('{computername}') + '\' + ExpandConstant('{username}');
    RepositoryPage.Values[1] := '';

    { Change text color for textboxes }
    RepositoryPage.Edits[1].Font.Color := $ffffff;

end;

服务页:

在此处输入图片说明

[Code]
procedure CreateServicePage;
var
    SSLNameArray : TArrayOfString;
    i : Integer;
begin

    ServicePage := CreateInputQueryPage(RepositoryPage.ID, 'Web server configuration',  '' , '');

    { Username. ServicePage.Edits[0] }
    ServicePage.Add('', False);
    { Password. ServicePage.Edits[1] }
    ServicePage.Add('', True);
    { Confirm Password. ServicePage.Edits[2] }
    ServicePage.Add('', True);

    { Http server configuration }

    {   Http checkbox  }
    HttpServerOptionCheckBox := TNewCheckBox.Create(ServicePage);
    with HttpServerOptionCheckBox do
    begin
        Parent := ServicePage.Surface;
        Top := ScaleY(0);
        Left := 0;
        Width := ScaleX(350);
        Caption := 'HTTP web server';
        Checked := True;
        OnClick := @OnHttpServerOptionCheckBox;
    end;

    {   Label for Http port }
    LblHttpPort := TNewStaticText.Create(ServicePage);
    with LblHttpPort do
    begin
        Parent := ServicePage.Surface;
        Left := ScaleX(15);
        Top := HttpServerOptionCheckBox.Top + HttpServerOptionCheckBox.Height + ScaleY(5);
        Width := ServicePage.SurfaceWidth;
        AutoSize := False;
        TabOrder := 1;
        Caption := 'Server port:';
    end;

    {   Edit for Http port }
    HttpPortTextBox := TNewEdit.Create(ServicePage);
    with HttpPortTextBox do
    begin
        Parent := ServicePage.Surface;
        Top := LblHttpPort.Top + LblHttpPort.Height + ScaleY(2);
        Left := ScaleX(15);
        Width := ScaleX(60);
        Text := '5019';
        Font.Color := $ffffff;
    end;

    {   Test button for testing Http port }
    TestHttpPortButton := TNewButton.Create(ServicePage);
    with TestHttpPortButton do
    begin
        Parent := ServicePage.Surface;
        Top := HttpPortTextBox.Top - ScaleY(2);
        Left := HttpPortTextBox.Width + ScaleX(20);
        Width := ScaleX(75);
        Height := ScaleY(23);
        OnClick := @TestHttpPortButtonOnClick;
        Caption := 'Test';
    end;

    { Checkbox for Http port firewall exception }
    CreateAddFirewallexceptionHttpCheckBox := TNewCheckBox.Create(ServicePage);
    with CreateAddFirewallexceptionHttpCheckBox do
    begin
        Parent := ServicePage.Surface;
        Top := HttpPortTextBox.Top + HttpPortTextBox.Height + ScaleY(5);
        Left := ScaleX(15);
        Width := ScaleX(350);
        Height := ScaleY(17);
        Caption := 'Create a firewall exception for the specified port';
        Checked := True;
    end;

    { //////////////////////////////////////////////////////////////////////////////////// }

    { Https server checkbox  }
    HttpsServerOptionCheckBox := TNewCheckBox.Create(ServicePage);
    with HttpsServerOptionCheckBox do
    begin
        Parent := ServicePage.Surface;
        Top := CreateAddFirewallexceptionHttpCheckBox.Top + CreateAddFirewallexceptionHttpCheckBox.Height + ScaleY(20);
        Left := 0;
        Width := ScaleX(120);
        Height := ScaleY(17);
        Caption := 'HTTPS web server';
        Checked := False;
        OnClick := @OnHttpsServerOptionCheckBox;
    end;

    { Https server port label    }
    LblHttpsPort := TNewStaticText.Create(ServicePage);
    with LblHttpsPort do
    begin
        Parent := ServicePage.Surface;
        Left := ScaleX(15);
        Top := HttpsServerOptionCheckBox.Top + HttpsServerOptionCheckBox.Height + ScaleY(2);
        Width := ScaleX(60);
        Height := ScaleY(17);
        AutoSize := False;
        Caption := 'Server port: ';
    end;

    { Https server port edit     }
    HttpsPortTextBox := TNewEdit.Create(ServicePage);
    with HttpsPortTextBox do
    begin
        Parent := ServicePage.Surface;
        Top := LblHttpsPort.Top + LblHttpsPort.Height;
        Left := LblHttpsPort.Left;
        Width := ScaleX(60);
        Height := ScaleY(17);
        Text := '4443';
        Font.Color := $ffffff;
    end;

    { Https server site name label  }
    LblSiteName := TNewStaticText.Create(ServicePage);
    with LblSiteName do
    begin
        Parent := ServicePage.Surface;
        Left := HttpsPortTextBox.Left + HttpsPortTextBox.Width +    ScaleX(10);
        Top := HttpsServerOptionCheckBox.Top + HttpsServerOptionCheckBox.Height + ScaleY(2);
        Width := ScaleX(98);
        Height := ScaleY(17);
        AutoSize := False;
        Caption := 'Host name or IP:';
    end;

    { Https server site name edit }
    HttpsSiteNameTextBox := TNewEdit.Create(ServicePage);
    with HttpsSiteNameTextBox do
    begin
        Parent := ServicePage.Surface;
        Top := LblSiteName.Top + LblSiteName.Height;
        Left := LblSiteName.Left;
        Width := ScaleX(140);
        Height := ScaleY(17);
        Text := '';
        Font.Color := $ffffff;
    end;

    LblSSLName := TNewStaticText.Create(ServicePage);
    with LblSSLName do
    begin
        Parent := ServicePage.Surface;
        Left := HttpsSiteNameTextBox.Left + HttpsSiteNameTextBox.Width + ScaleX(10) ;
        Top := HttpsServerOptionCheckBox.Top + HttpsServerOptionCheckBox.Height + ScaleY(2);
        Width := ScaleX(50);
        Height := ScaleY(17);
        AutoSize := False;
        Caption := 'SSL: ';
    end;

    SSLComboBox := TNewComboBox.Create(RepositoryPage);
    with SSLComboBox do
    begin
        Parent := ServicePage.Surface;
        Style := csDropDown;
        Left := LblSSLName.Left;
        Top := LblSSLName.Top + LblSSLName.Height;
        Width := ScaleX(150);
        Height := ScaleY(17);
        ItemIndex := 0;
    end;

    if not (IsAppUpgrade or IsSameVersion) then begin
         SSLNameArray := GetSSLCertificates();
         for i:= 0 to GetArrayLength(SSLNameArray)-1 do begin
                SSLComboBox.Items.Add(SSLNameArray[i])
         end;
    end;

        {   Test button for testing Https port }
    TestHttpsPortButton := TNewButton.Create(ServicePage);
    with TestHttpsPortButton do
    begin
        Parent := ServicePage.Surface;
        Top := SSLComboBox.Top - ScaleY(2);
        Left := SSLComboBox.Left + SSLComboBox.Width + ScaleX(5);
        Width := ScaleX(75);
        Height := ScaleY(23);
        OnClick := @TestHttpsPortButtonOnClick;
        Caption := 'Test';
    end;

    CreateAddFirewallexceptionHttpsCheckBox := TNewCheckBox.Create(ServicePage);
    with CreateAddFirewallexceptionHttpsCheckBox do
    begin
        Parent := ServicePage.Surface;
        Top := HttpsSiteNameTextBox.Top + HttpsSiteNameTextBox.Height + ScaleY(5);
        Left := ScaleX(15);
        Width := ScaleX(350);
        Height := ScaleY(17);
        Caption := 'Create a firewall exception for the specified port';
        Checked := True;
    end;

    { User managment }
    LblServicePageUser := TNewStaticText.Create(ServicePage);
    with LblServicePageUser do
    begin
        Parent := ServicePage.Surface;
        Top := CreateAddFirewallexceptionHttpsCheckBox.Top + CreateAddFirewallexceptionHttpsCheckBox.Height + ScaleY(15);
        Left := 0;
        Width := ServicePage.SurfaceWidth;
        Height := ScaleY(0);
        AutoSize := False;
        Caption := 'Application user';
    end;

    LblServicePageUsername := TNewStaticText.Create(ServicePage);
    with LblServicePageUsername do
    begin
        Parent := ServicePage.Surface;
        Left := 0;
        Top := LblServicePageUser.Top + LblServicePageUser.Height + ScaleY(5);
        Width := ServicePage.SurfaceWidth;
        Height := ScaleY(17);
        AutoSize := False;
        Caption := 'Application username: ';
    end;

    ServicePage.Values[0] := strMonitorUser;
    ServicePage.Edits[0].Top := LblServicePageUsername.Top + LblServicePageUsername.Height;

    LblServicePagePassword := TNewStaticText.Create(ServicePage);
    with LblServicePagePassword do
    begin
        Parent := ServicePage.Surface;
        Left := 0;
        Top := ServicePage.Edits[0].Top + ServicePage.Edits[0].Height + ScaleY(5);
        Width := ServicePage.SurfaceWidth;
        Height := ScaleY(17);
        AutoSize := False;
        Caption := 'New password: ';
    end;

    ServicePage.Edits[1].Top := LblServicePagePassword.Top + LblServicePagePassword.Height;

    LblServicePageConfirmPassword := TNewStaticText.Create(ServicePage);
    with LblServicePageConfirmPassword do
    begin
        Parent := ServicePage.Surface;
        Left := 0;
        Top := ServicePage.Edits[1].Top + ServicePage.Edits[1].Height + ScaleY(2);
        Width := ServicePage.SurfaceWidth;
        Height := ScaleY(17);
        AutoSize := False;
        Caption := 'Confirm password: ';
    end;

    ServicePage.Edits[2].Top := LblServicePageConfirmPassword.Top + LblServicePageConfirmPassword.Height;

    EnableServicePageElements;

    { Change text color for textboxes }
    ServicePage.Edits[0].Font.Color := $ffffff;
    ServicePage.Edits[1].Font.Color := $ffffff;
    ServicePage.Edits[2].Font.Color := $ffffff;

    OnHttpServerOptionCheckBox( HttpServerOptionCheckBox);
    OnHttpsServerOptionCheckBox( HttpsServerOptionCheckBox);

end;

ConfigForm包含ServicePage中的所有元素RepositoryPage,它仅用于创建配置文件(稍后将使用),并且与安装程序分开(之前和之后没有页面)。如何制作ConfigForm如下图所示的自定义

在此处输入图片说明

马丁·普里克里(Martin Prikryl)

检查示例文件中使用CreateCustomForm函数CodeClasses.iss示例

procedure FormButtonOnClick(Sender: TObject);
var
  Form: TSetupForm;
  Edit: TNewEdit;
  OKButton, CancelButton: TNewButton;
begin
  Form := CreateCustomForm();
  try
    Form.ClientWidth := ScaleX(256);
    Form.ClientHeight := ScaleY(128);
    Form.Caption := 'TSetupForm';

    Edit := TNewEdit.Create(Form);
    Edit.Top := ScaleY(10);
    Edit.Left := ScaleX(10);
    Edit.Width := Form.ClientWidth - ScaleX(2 * 10);
    Edit.Height := ScaleY(23);
    Edit.Anchors := [akLeft, akTop, akRight];
    Edit.Text := 'TNewEdit';
    Edit.Parent := Form;

    OKButton := TNewButton.Create(Form);
    OKButton.Parent := Form;
    OKButton.Left := Form.ClientWidth - ScaleX(75 + 6 + 75 + 10);
    OKButton.Top := Form.ClientHeight - ScaleY(23 + 10);
    OKButton.Width := ScaleX(75);
    OKButton.Height := ScaleY(23);
    OKButton.Anchors := [akRight, akBottom]
    OKButton.Caption := 'OK';
    OKButton.ModalResult := mrOk;
    OKButton.Default := True;

    CancelButton := TNewButton.Create(Form);
    CancelButton.Parent := Form;
    CancelButton.Left := Form.ClientWidth - ScaleX(75 + 10);
    CancelButton.Top := Form.ClientHeight - ScaleY(23 + 10);
    CancelButton.Width := ScaleX(75);
    CancelButton.Height := ScaleY(23);
    CancelButton.Anchors := [akRight, akBottom]
    CancelButton.Caption := 'Cancel';
    CancelButton.ModalResult := mrCancel;
    CancelButton.Cancel := True;

    Form.ActiveControl := Edit;
    { Keep the form from sizing vertically since we don't have any controls which can size vertically }
    Form.KeepSizeY := True;
    { Center on WizardForm. Without this call it will still automatically center, but on the screen }
    Form.FlipSizeAndCenterIfNeeded(True, WizardForm, False);

    if Form.ShowModal() = mrOk then
      MsgBox('You clicked OK.', mbInformation, MB_OK);
  finally
    Form.Free();
  end;
end;

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

Inno Setup的自定义页面向导

来自分类Dev

如何在Inno Setup中引用文件关联的自定义图标?

来自分类Dev

在Inno-Setup中使用自定义DLL

来自分类Dev

Inno Setup语言对话框自定义

来自分类Dev

Inno Setup在下次安装时记住“自定义”复选框状态

来自分类Dev

Inno Setup相对于现有按钮定位自定义按钮

来自分类Dev

Chrome的Inno设置自定义网址

来自分类Dev

Inno Setup:“就绪页面”自定义布局

来自分类Dev

每个用户或每个计算机安装的Inno Setup自定义对话框

来自分类Dev

Inno Setup:从另一个控件的OnClick事件访问自定义控件

来自分类Dev

如何添加可点击的链接到自定义的Inno Setup WelcomeLabel?

来自分类Dev

Inno Setup:自定义类

来自分类Dev

Inno Setup如何在自定义消息中添加CRLF /换行符

来自分类Dev

Inno Setup安装程序默认为“自定义”安装,而不是“完全”安装

来自分类Dev

Inno Setup中的自定义消息和占位符文本

来自分类Dev

如何在Inno Setup中基于设置类型跳过自定义页面

来自分类Dev

在Inno Setup中,FinishedPage上未显示自定义TLabel

来自分类Dev

如何使用RichEditViewer在Inno Setup中向自定义页面添加可点击链接?

来自分类Dev

为什么在Inno Setup中未选中自定义页面上的单选按钮?

来自分类Dev

自定义页面Values []数组在Inno Setup中如何工作?

来自分类Dev

Inno Setup中自定义页面画布区域的默认大小是多少?

来自分类Dev

Inno Setup Preprocessor可以用于构建重复的自定义消息集吗?

来自分类Dev

Inno Setup使用Pascal脚本自定义FinishedLabel

来自分类Dev

Inno Setup的自定义页面向导

来自分类Dev

使用Google Map的Inno Setup自定义页面

来自分类Dev

Inno Setup:自定义类

来自分类Dev

Inno Setup - 如何在自定义卸载页面中创建新的卸载页面?

来自分类Dev

Inno Setup:自定义页面选择更新或删除/卸载

来自分类Dev

Inno Setup - 创建自定义消息框(是/否)

Related 相关文章

  1. 1

    Inno Setup的自定义页面向导

  2. 2

    如何在Inno Setup中引用文件关联的自定义图标?

  3. 3

    在Inno-Setup中使用自定义DLL

  4. 4

    Inno Setup语言对话框自定义

  5. 5

    Inno Setup在下次安装时记住“自定义”复选框状态

  6. 6

    Inno Setup相对于现有按钮定位自定义按钮

  7. 7

    Chrome的Inno设置自定义网址

  8. 8

    Inno Setup:“就绪页面”自定义布局

  9. 9

    每个用户或每个计算机安装的Inno Setup自定义对话框

  10. 10

    Inno Setup:从另一个控件的OnClick事件访问自定义控件

  11. 11

    如何添加可点击的链接到自定义的Inno Setup WelcomeLabel?

  12. 12

    Inno Setup:自定义类

  13. 13

    Inno Setup如何在自定义消息中添加CRLF /换行符

  14. 14

    Inno Setup安装程序默认为“自定义”安装,而不是“完全”安装

  15. 15

    Inno Setup中的自定义消息和占位符文本

  16. 16

    如何在Inno Setup中基于设置类型跳过自定义页面

  17. 17

    在Inno Setup中,FinishedPage上未显示自定义TLabel

  18. 18

    如何使用RichEditViewer在Inno Setup中向自定义页面添加可点击链接?

  19. 19

    为什么在Inno Setup中未选中自定义页面上的单选按钮?

  20. 20

    自定义页面Values []数组在Inno Setup中如何工作?

  21. 21

    Inno Setup中自定义页面画布区域的默认大小是多少?

  22. 22

    Inno Setup Preprocessor可以用于构建重复的自定义消息集吗?

  23. 23

    Inno Setup使用Pascal脚本自定义FinishedLabel

  24. 24

    Inno Setup的自定义页面向导

  25. 25

    使用Google Map的Inno Setup自定义页面

  26. 26

    Inno Setup:自定义类

  27. 27

    Inno Setup - 如何在自定义卸载页面中创建新的卸载页面?

  28. 28

    Inno Setup:自定义页面选择更新或删除/卸载

  29. 29

    Inno Setup - 创建自定义消息框(是/否)

热门标签

归档