In an Inno setup, how do I center some text in a window?

In an Inno setup, how do I place some text in the window? I tried to make it a TLabel and set the Alignment to taCenter, but it had no effect. I can install Left and Top with no problem.

+3


source to share


1 answer


The property Alignment

controls the horizontal placement of the text inside the label. It is not used to position controls within their parent. Except for the Align

property (which stretches the controls to the specified space), there is no way to centralize the 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;

      

+3


source







All Articles