【问题标题】:In Inno Setup, how do I center some text in the window?在 Inno Setup 中,如何在窗口中居中放置一些文本?
【发布时间】:2014-10-12 15:03:50
【问题描述】:

在 Inno Setup 中,如何在窗口中居中放置一些文本?我尝试将其设为TLabel 并将Alignment 设置为taCenter,但没有任何效果。我可以毫无问题地设置LeftTop

【问题讨论】:

    标签: inno-setup centering pascalscript


    【解决方案1】:

    Alignment 属性控制标签内文本的水平位置。它不用于将控件定位在其父级中。除了Align 属性(将控件拉伸到给定空间)之外,没有办法将控件集中到其父级。但是你可以为此创建一个函数:

    [Code]
    procedure CenterInParent(Control: TControl);
    begin
      if Assigned(Control) and Assigned(Control.Parent) then
      begin
        Control.Left := (Control.Parent.Width - Control.Width) div 2;
        Control.Top := (Control.Parent.Height - Control.Height) div 2;
      end;
    end;
    
    procedure InitializeWizard;
    var
      MyPage: TWizardPage;
      MyLabel: TLabel;
    begin
      MyPage := CreateCustomPage(wpWelcome, 'Caption', 'Description');
    
      MyLabel := TLabel.Create(MyPage);
      MyLabel.Parent := MyPage.Surface;
      MyLabel.Caption := 'Hello!';
    
      CenterInParent(MyLabel);
    end;
    

    【讨论】:

      猜你喜欢
      • 2012-01-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-06-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多