In Inno Setup, how do I center some text in the window?

折月煮酒 提交于 2020-08-24 12:00:26

问题


In Inno Setup, how do I center some text in the window? I tried making it a TLabel and setting the Alignment to taCenter but it didn't have any effect. I can set the Left and Top with no problems.


回答1:


The Alignment property controls the horizontal placement of the text within the label. It's not used to position controls within their parent. Except Align property (which stretches controls to given space), there is no way to center controls to their parents. But you can make a function for this:

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


来源:https://stackoverflow.com/questions/25384671/in-inno-setup-how-do-i-center-some-text-in-the-window

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!