2014-02-18 91 views
1

我遇到组件页面中关于按钮的问题。 它在第一页中正常工作,但尺寸较小,但看起来像这样(请参见下面的截图)。INNO设置:“关于”按钮位置

enter image description here

的代码是这一个:

[Setup] 
    AppName=My Program 
    AppVersion=1.5 
    DefaultDirName={pf}\My Program 
    DefaultGroupName=My Program 
    UninstallDisplayIcon={app}\MyProg.exe 
    OutputDir=userdocs:Inno Setup Examples Output 


    [Types] 
    Name: "full"; Description: "Full installation" 
    Name: "compact"; Description: "Compact installation" 
    Name: "custom"; Description: "Custom installation"; Flags: iscustom 

    [Components] 
    Name: "program"; Description: "Program Files"; Types: full compact custom; Flags: fixed 
    Name: "help"; Description: "Help File"; Types: full 
    Name: "readme"; Description: "Readme File"; Types: full 
    Name: "readme\en"; Description: "English"; Flags: exclusive 
    Name: "readme\de"; Description: "German"; Flags: exclusive 

    [Code] 
    procedure AboutButtonOnClick(Sender: TObject); 
    begin 
     MsgBox('This is a demo of how to create a button!', mbInformation, mb_Ok); 
    end; 

    procedure CreateAboutButton(ParentForm: TSetupForm; CancelButton: TNewButton); 
    var 
     AboutButton: TNewButton; 
    begin 
     AboutButton := TNewButton.Create(ParentForm); 
     AboutButton.Left := ParentForm.ClientWidth - CancelButton.Left - CancelButton.Width; 
     AboutButton.Top := CancelButton.Top; 
     AboutButton.Width := CancelButton.Width; 
     AboutButton.Height := CancelButton.Height; 
     AboutButton.Caption := '&About...'; 
     AboutButton.OnClick := @AboutButtonOnClick; 
     AboutButton.Parent := ParentForm; 
    end; 


    procedure InitializeWizard1(); 
    begin 
     CreateAboutButton(WizardForm, WizardForm.CancelButton); 
    end; 

    type 
     TPositionStorage = array of Integer; 

    var 
     CompPageModified: Boolean; 
     CompPagePositions: TPositionStorage; 

    procedure SaveComponentsPage(out Storage: TPositionStorage); 
    begin 
     SetArrayLength(Storage, 10); 

     Storage[0] := WizardForm.Height; 
     Storage[1] := WizardForm.NextButton.Top; 
     Storage[2] := WizardForm.BackButton.Top; 
     Storage[3] := WizardForm.CancelButton.Top; 
     Storage[4] := WizardForm.ComponentsList.Height; 
     Storage[5] := WizardForm.OuterNotebook.Height; 
     Storage[6] := WizardForm.InnerNotebook.Height; 
     Storage[7] := WizardForm.Bevel.Top; 
     Storage[8] := WizardForm.BeveledLabel.Top; 
     Storage[9] := WizardForm.ComponentsDiskSpaceLabel.Top; 
    end; 

    procedure LoadComponentsPage(const Storage: TPositionStorage; 
     HeightOffset: Integer); 
    begin 
     if GetArrayLength(Storage) <> 10 then 
     RaiseException('Invalid storage array length.'); 

     WizardForm.Height := Storage[0] + HeightOffset; 
     WizardForm.NextButton.Top := Storage[1] + HeightOffset; 
     WizardForm.BackButton.Top := Storage[2] + HeightOffset; 
     WizardForm.CancelButton.Top := Storage[3] + HeightOffset; 
     WizardForm.ComponentsList.Height := Storage[4] + HeightOffset; 
     WizardForm.OuterNotebook.Height := Storage[5] + HeightOffset; 
     WizardForm.InnerNotebook.Height := Storage[6] + HeightOffset; 
     WizardForm.Bevel.Top := Storage[7] + HeightOffset; 
     WizardForm.BeveledLabel.Top := Storage[8] + HeightOffset; 
     WizardForm.ComponentsDiskSpaceLabel.Top := Storage[9] + HeightOffset; 
    end; 

    procedure InitializeWizard2(); 
    begin 
     CompPageModified := False; 
    end; 

    procedure CurPageChanged(CurPageID: Integer); 
    begin 
     if CurpageID = wpSelectComponents then 
     begin 
     SaveComponentsPage(CompPagePositions); 
     LoadComponentsPage(CompPagePositions, 200); 
     CompPageModified := True; 
     end 
     else 
     if CompPageModified then 
     begin 
     LoadComponentsPage(CompPagePositions, 0); 
     CompPageModified := False; 
     end; 
    end; 

     procedure InitializeWizard(); 
     begin 
     InitializeWizard1(); 
     InitializeWizard2(); 
     end; 

谁能帮助我?先进的非常感谢。

回答

1

由于缺少缺少Anchors属性,当表单被调整大小时,您将不得不自己移动该按钮。所以,你可以在你的脚本中做什么是发布按钮实例,并扩展你的按钮的垂直位置的现有位置存储。在代码中它可能看起来像这样:

[Setup] 
AppName=My Program 
AppVersion=1.5 
DefaultDirName={pf}\My Program 
DefaultGroupName=My Program 
UninstallDisplayIcon={app}\MyProg.exe 
OutputDir=userdocs:Inno Setup Examples Output 

[Types] 
Name: "full"; Description: "Full installation" 
Name: "compact"; Description: "Compact installation" 
Name: "custom"; Description: "Custom installation"; Flags: iscustom 

[Components] 
Name: "program"; Description: "Program Files"; Types: full compact custom; Flags: fixed 
Name: "help"; Description: "Help File"; Types: full 
Name: "readme"; Description: "Readme File"; Types: full 
Name: "readme\en"; Description: "English"; Flags: exclusive 
Name: "readme\de"; Description: "German"; Flags: exclusive 

[Code] 
type 
    TPositionStorage = array of Integer; 

var 
    AboutButton: TNewButton; 
    CompPageModified: Boolean; 
    CompPagePositions: TPositionStorage; 

procedure AboutButtonOnClick(Sender: TObject); 
begin 
    MsgBox('This is a demo of how to create a button!', mbInformation, mb_Ok); 
end; 

function CreateAboutButton(ParentForm: TSetupForm; CancelButton: TNewButton): TNewButton; 
begin 
    Result := TNewButton.Create(ParentForm); 
    Result.Left := ParentForm.ClientWidth - CancelButton.Left - CancelButton.Width; 
    Result.Top := CancelButton.Top; 
    Result.Width := CancelButton.Width; 
    Result.Height := CancelButton.Height; 
    Result.Caption := '&About...'; 
    Result.OnClick := @AboutButtonOnClick; 
    Result.Parent := ParentForm; 
end; 

procedure SaveComponentsPage(out Storage: TPositionStorage); 
begin 
    SetArrayLength(Storage, 11); 

    Storage[0] := AboutButton.Top; 
    Storage[1] := WizardForm.Height; 
    Storage[2] := WizardForm.NextButton.Top; 
    Storage[3] := WizardForm.BackButton.Top; 
    Storage[4] := WizardForm.CancelButton.Top; 
    Storage[5] := WizardForm.ComponentsList.Height; 
    Storage[6] := WizardForm.OuterNotebook.Height; 
    Storage[7] := WizardForm.InnerNotebook.Height; 
    Storage[8] := WizardForm.Bevel.Top; 
    Storage[9] := WizardForm.BeveledLabel.Top; 
    Storage[10] := WizardForm.ComponentsDiskSpaceLabel.Top; 
end; 

procedure LoadComponentsPage(const Storage: TPositionStorage; 
    HeightOffset: Integer); 
begin 
    if GetArrayLength(Storage) <> 11 then 
    RaiseException('Invalid storage array length.'); 

    AboutButton.Top := Storage[0] + HeightOffset; 
    WizardForm.Height := Storage[1] + HeightOffset; 
    WizardForm.NextButton.Top := Storage[2] + HeightOffset; 
    WizardForm.BackButton.Top := Storage[3] + HeightOffset; 
    WizardForm.CancelButton.Top := Storage[4] + HeightOffset; 
    WizardForm.ComponentsList.Height := Storage[5] + HeightOffset; 
    WizardForm.OuterNotebook.Height := Storage[6] + HeightOffset; 
    WizardForm.InnerNotebook.Height := Storage[7] + HeightOffset; 
    WizardForm.Bevel.Top := Storage[8] + HeightOffset; 
    WizardForm.BeveledLabel.Top := Storage[9] + HeightOffset; 
    WizardForm.ComponentsDiskSpaceLabel.Top := Storage[10] + HeightOffset; 
end; 

procedure CurPageChanged(CurPageID: Integer); 
begin 
    if CurpageID = wpSelectComponents then 
    begin 
    SaveComponentsPage(CompPagePositions); 
    LoadComponentsPage(CompPagePositions, 200); 
    CompPageModified := True; 
    end 
    else 
    if CompPageModified then 
    begin 
    LoadComponentsPage(CompPagePositions, 0); 
    CompPageModified := False; 
    end; 
end; 

procedure InitializeWizard(); 
begin 
    CompPageModified := False; 
    AboutButton := CreateAboutButton(WizardForm, WizardForm.CancelButton); 
end; 
+1

感谢您的答复,一句问候 – DeXon

0

在我来说,我把一个关于按钮在同一行中的上一步和下一步和取消按钮。 以这种方式调整页面大小并不重要。 代码看起来如下:

// Create an About button 
AboutButton := TButton.Create(WizardForm); 
with AboutButton do 
    begin 
    Parent := WizardForm; 
    Left  := WizardForm.ClientWidth - CancelButton.Left - CommonWidth; 
    Top  := CancelButton.Top; 
    Width := CommonWidth; 
    Height := CommonHeight; 
    Caption := ExpandConstant('{cm:About}'); 
    OnClick := @HelpButtonClick; 
    ShowHint := True; 
    Hint  := ExpandConstant('{cm:AboutHint}'); 
    Name  := 'AboutButton'; 
    end; 

在初始化安装例程我把线:

CommonWidth   := ScaleX(75); // Standard width for new buttons 
CommonHeight   := ScaleY(23); // Standard heigth for new buttons 
+0

按钮是*“在同一行中” *作为下一步和取消按钮。就在OP调整了向导窗体的大小时,按钮的垂直位置仍然保持原来的垂直位置。这段代码也会遭受同样的影响。您可以尝试更改向导窗体的高度以查看它。此外,我敦促你不要使用那些声称他们是默认值的神奇常数值。如果您不明确更改其大小,将获得按钮的默认宽度和高度。 – TLama