In an Inno setup, how do I center some text in a window?
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 to share