INNO设置:“关于"按钮位置 [英] INNO Setup: "About" button position

查看:69
本文介绍了INNO设置:“关于"按钮位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在组件页面的关于"按钮上遇到问题. 当它较小时,它在首页上可以正常工作,但在本部分中看起来像这样(请参见下面的屏幕截图).

I'm having problems with the About button in the components page. It works fine in the first page, when it is smaller but it looks like this (see the following screenshot) in this part.

代码是这样的:

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

有人可以帮助我吗?非常感谢.

Could anyone help me? Thanks so much in advanced.

推荐答案

由于缺少缺少的Anchors属性,因此在调整表单大小时,您必须自行移动该按钮.因此,您可以在脚本中执行的操作是发布按钮实例,并扩展按钮垂直位置的现有位置存储.在代码中,它可能看起来像这样:

Due to a lack of missing Anchors property you will have to move that button by yourself when the form is being resized. So, what you can do in your script is publish the button instance and extend an existing position storage of the vertical position of your button. In code it may look like this:

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

这篇关于INNO设置:“关于"按钮位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆