Reputation: 339
Following on from this: Inno Setup Placing image/control on custom page.
This is doing what I need:
CustomPage := CreateCustomPage(wpLicense, 'Heading', 'Sub heading.');
ExtractTemporaryFile('image.bmp');
BtnImage := TBitmapImage.Create(WizardForm);
with BtnImage do
begin
Parent := CustomPage.Surface;
Bitmap.LoadFromFile(ExpandConstant('{tmp}')+'\image.bmp');
AutoSize := True;
AutoSize := False;
Height := ScaleX(Height);
Width := ScaleY(Width);
Stretch := True;
Left := ScaleX(90);
Top := WizardForm.SelectTasksPage.Top + WizardForm.SelectTasksPage.Height -
Height - ScaleY(8);
Cursor := crHand;
OnClick := @ImageOnClick;
end;
However I would like the background image to be the full size of the space bellow the heading and above the footer with no side margins. I was trying various stretch/margin/height/width, but the results are messy. What's the best way to achieve this that looks good no matter the DPI?
Upvotes: 3
Views: 2389
Reputation: 202118
You can retrieve a size of the (custom) page surface using TWizardPage.SurfaceHeight
and TWizardPage.SurfaceWidth
.
BtnImage.Height := CustomPage.SurfaceHeight;
BtnImage.Width := CustomPage.SurfaceWidth;
// Needed for WizardStyle=modern
BtnImage.Anchors := [akLeft, akTop, akRight, akBottom];
Though you will see that the (custom) page does not cover whole area between "header" (MainPanel
) and "footer" (bottom part with buttons).
If you want to display image across the whole area between "header" and "footer", you cannot place it on the (custom) page. You have to place it on the InnerPage
(what is a parent control of all pages with the "header").
BtnImage.Parent := WizardForm.InnerPage;
BtnImage.Left := 0;
BtnImage.Top := WizardForm.Bevel1.Top + 1;
BtnImage.Width := WizardForm.InnerPage.ClientWidth;
BtnImage.Height := WizardForm.InnerPage.ClientHeight - BtnImage.Top;
// Needed for WizardStyle=modern
BtnImage.Anchors := [akLeft, akTop, akRight, akBottom];
But that way the image won't get automatically shown/hidden as the custom page shows/hides. You have to code it. Use CurPageChanged
event function.
procedure CurPageChanged(CurPageID: Integer);
begin
WizardForm.InnerNoteBook.Visible := (CurPageID <> CustomPage.ID);
BtnImage.Visible := (CurPageID = CustomPage.ID);
end;
Similar questions:
Upvotes: 4