I am aware that is possible to create a custom button on any page and position it using absolute values using the following code:
//Create the About button
AboutButton := TButton.Create(WizardForm);
AboutButton.Caption := '&About';
AboutButton.Width := ScaleX(75);
AboutButton.Height := ScaleY(23);
AboutButton.Left := WizardForm.InfoAfterPage.Left + 10;
AboutButton.Top := WizardForm.InfoAfterPage.Height + 90;
AboutButton.OnClick := @AboutButtonClick;
AboutButton.Parent := WizardForm.NextButton.Parent;
The only problem with this is that since it uses absolute values for positioning, if the user has Windows scaling switched on (under Screen Resolution > Make text and other items larger or smaller) and scaling is set to Medium 125%, the buttons then appear out of alignment with the other built-in buttons resulting in a nasty mess. Therefore, is there a way to position any newly created custom buttons in relation to the built-in buttons, so that they always appear in-line and as they were intended? Or is there another solution to this scaling dilemma that I am overlooking?
This is how I would write it:
AboutButton := TButton.Create(WizardForm);
AboutButton.Caption := '&About';
AboutButton.Left := WizardForm.InfoAfterPage.Left + (WizardForm.ClientWidth -
(WizardForm.CancelButton.Left + WizardForm.CancelButton.Width));
// sets Left position from the Page Left
// + already scaled gap calculated on the basis of TLama's recommendations
AboutButton.Width := WizardForm.NextButton.Width;
// sets same Width as NextButton
AboutButton.Top := WizardForm.NextButton.Top;
// sets same Top position as NextButton
AboutButton.Height := WizardForm.NextButton.Height;
// sets same Height as NextButton
AboutButton.OnClick := @AboutButtonClick;
AboutButton.Parent := WizardForm.NextButton.Parent;
Examples:
96 (Default)
120 (125%)
144 (150%)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With