Inno设置:创建自定义表单

问题描述 投票:1回答:2

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

RepositoryPage:

enter image description here

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;

ServicePage:

enter image description here

[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包含ServicePageRepositoryPage中的所有元素,它仅用于创建配置文件(稍后使用),并且与安装程序分开(之前和之后没有页面)。如何制作自定义ConfigForm,如下图所示?

enter image description here

windows installer inno-setup pascalscript
2个回答
0
投票

检查CreateCustomForm function中使用CreateCustomForm的示例:

CodeClasses.iss example file

0
投票

您是否检查了CodeClasses.iss的Inno Setup?

这是一个新工具,可帮助您轻松设计Inno Setup对话框页面而无需编写任何脚本(带有拖放功能的WYSIWIG编辑器)。

有了它,在Inno Setup中创建任何页面比手动编写代码要快得多。

((我是该工具的开发人员,如果您有任何问题,请随时在此处发布任何问题,]。

© www.soinside.com 2019 - 2024. All rights reserved.