I'm trying to have an image on a custom page I can get the custom page to show or the image on a predefined page but not on the custom page.
Problem I think is with Parent := CustomPage.ID;.
Parent := WizardForm.SelectTasksPage; works though.
How to do this properly?
procedure ImageOnClick(Sender: TObject);
var
ErrorCode: Integer;
begin
ShellExec('', 'http://test.com', '', '', SW_SHOW, ewNoWait, ErrorCode);
end;
var
CustomPage: TWizardPage;
BtnImage: TBitmapImage;
procedure InitializeWizard;
begin
CustomPage := CreateCustomPage(wpLicense, 'Heading', 'Sub heading.');
ExtractTemporaryFile('image.bmp');
BtnImage := TBitmapImage.Create(WizardForm);
with BtnImage do
begin
Parent := CustomPage.ID;
Bitmap.LoadFromFile(ExpandConstant('{tmp}')+'\image.bmp');
AutoSize := True;
Left := 90;
Top := WizardForm.SelectTasksPage.Top +
WizardForm.SelectTasksPage.Height - Height - 8;
Cursor := crHand;
OnClick := #ImageOnClick;
end;
end;
That's what TWizardPage.Surface of type TNewNotebookPage is for.
with BtnImage do
begin
Parent := CustomPage.Surface;
{ ... }
end;
Related questions:
TInputDirWizardPage with Radio Buttons
(Similar question about radio buttons with more code)
Add additional controls to standard Inno Setup pages?
Also, never use absolute coordinates and sizes. Your layout will break, when the wizard is shown on high DPI/scaled display, what is quite common nowadays with "retina" displays. Use ScaleX and ScaleY functions. For the same reason, you should have images with different resolutions ready (see Inno Setup WizardImageFile looks bad with font scaling on Windows 7). Or at least scale/stretch the bitmap.
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 := ScaleY(Height);
Width := ScaleX(Width);
Stretch := True;
Left := ScaleX(90);
Top := WizardForm.SelectTasksPage.Top + WizardForm.SelectTasksPage.Height -
Height - ScaleY(8);
Cursor := crHand;
OnClick := #ImageOnClick;
end;
Layout on 100% zoom (96 DPI):
Layout on 150% zoom (144 DPI):
Layout on 150% zoom (144 DPI) with offset/sizes scaling and image stretching:
Similar to Martin Prikryl's answer.
In order to deal with different DPI settings and placing a bitmap:
setup your machine to 100% DPI
make a bitmap with size (width/height) to fit on your InnoSetup page/form
get these width and height (right click/properties on your bmp file)
use the code below
setup your machine to 150% DPI and create your bitmap to fit for 150% DPI and use it instead the first one (which fits for 100% DPI), this way it will look nice for 100% and for 200%
The code:
WarningImage := TBitmapImage.Create(RisksForm);
WarningImage.Parent := RisksForm;
WarningImage.Bitmap.LoadFromFile(ExpandConstant('{app}')+'uninstall-warning-large.bmp');
WarningImage.Left := ScaleX(24);
WarningImage.Top := ScaleY(120);
WarningImage.Width := ScaleX(544);
WarningImage.Height := ScaleY(211);
WarningImage.Stretch := True;
Change 544 with the width of your bitmap and 211 with the height of your bitmap (from step 3)
Stretch := True does the bitmap to expand (if it is smaller) or shrink (if it is bigger) than width/height properties
P.S. ofcourse you could use multiple files and use one depending on users DPI settings (DPI settings with Inno Setup), but bitmaps are without compressions, so I don't like this idea.
you can Use Botva2 library
http://krinkels.org/threads/botva2.1931/
use google translate if u can't understand rusian
u can create some awesome installer using this
image f.e
Botva2 example
[code]
#include "botva2.iss"
var SomeImage : Longint;
procedure InitializeWizard();
begin
{Your Custom page Code Goes Here}
SomeImage := ImgLoad(WizardForm.Handle,'Image.bmp',0,0,854,480,true,true);
end;
procedure CurPageChanged(CurPageID: Integer);
begin
ImgSetVisibility(SomeImage,false);
if (CurPageID = CustomPage.ID) ImgSetVisibility(SomeImage,true);
end;
Related
I placed a Panel on my custom page and gave it a width of SurfaceWidth. Then I changed its width to SurfaceWidth div 2. Here's the result:
As you can see from the screenshot the new panel's width is definitely not equal to SurfaceWidth div 2. Why is that so?
Here's the code:
[Setup]
WizardStyle=modern
[Code]
procedure InitializeWizard();
var
Page: TWizardPage;
Panel: TPanel;
begin
Page := CreateCustomPage(wpWelcome, 'Custom wizard page controls', 'TButton and others');
Panel := TPanel.Create(Page);
Panel.Width := Page.SurfaceWidth div 2;
Panel.Left := 0;
Panel.Height := 46;
Panel.Anchors := [akLeft, akTop, akRight];
Panel.Caption := 'TPanel';
Panel.Color := clWindow;
Panel.BevelKind := bkFlat;
Panel.BevelOuter := bvNone;
Panel.ParentBackground := False;
Panel.Parent := Page.Surface;
end;
That's because of the akRight in Panel.Anchors and modern WizardStyle (or rather the 120 WizardSizePercent it implies). The wizard is scaled only after the InitializeWizard. With akRight, the panel width will grow linearly (not proportionally) with the wizard. There are solutions, but they depend on how you actually want the panel to behave in the resizable wizard (also implied by the modern style).
See also Inno Setup - how to center an animated gif in resized wizard.
If you want to keep the panel at half size, when the wizard is resized (either automatically due to WizardSizePercent or by the user due to WizardResizable), handle WizardForm.OnResize:
[Code]
var
Page: TWizardPage;
Panel: TPanel;
procedure WizardFormResize(Sender: TObject);
begin
Panel.Width := Page.SurfaceWidth div 2;
end;
procedure InitializeWizard();
begin
Page := CreateCustomPage(
wpWelcome, 'Custom wizard page controls', 'TButton and others');
Panel := TPanel.Create(Page);
Panel.Width := Page.SurfaceWidth div 2;
// ...
WizardForm.OnResize := #WizardFormResize;
end;
Make sure you do not set the akRight anchor.
How can I add an image to the setup wizard, the bottom left?
As #TLama commented: Create a TBitmapImage, set its parent to WizardForm, position it where you want and load the picture from file.
[Files]
Source: "logo.bmp"; Flags: dontcopy
[Code]
<event('InitializeWizard')>
procedure InitializeWizardAddLogo();
var
Image: TBitmapImage;
begin
Image := TBitmapImage.Create(WizardForm);
with Image do
begin
Parent := WizardForm;
ExtractTemporaryFile('logo.bmp');
Bitmap.LoadFromFile(ExpandConstant('{tmp}')+'\logo.bmp');
AutoSize := True;
AutoSize := False;
Width := ScaleX(Width);
Height := ScaleY(Height);
Stretch := True;
Left := ScaleX(10);
Top :=
(WizardForm.ClientHeight + WizardForm.Bevel.Top +
WizardForm.Bevel.Height - Height)
div 2;
end;
end;
(the code [with event attribute] is for Inno Setup 6)
Though tricky part is to handle screen scaling correctly. Hence, the AutoSize trick and Scale* calls.
You even might need to have different versions of the logo for different scaling factors.
See Inno Setup WizardImageFile looks bad with font scaling on Windows 7
In Inno Setup, I am trying to change the color of the setup to white. The problem is that when I try to do it by the Unicode version of installer, in the Select Additional Task Screen, I am getting grey section (screenshot is below). The important part is that when I move to next screen and comes back to that screen again, that grey section is gone.
I am using following code, based on Inno Setup: How to change background color.
procedure CurPageChanged(CurPageID: Integer);
begin
case CurPageID of
wpWelcome: WizardForm.Color := WizardForm.WelcomePage.Color;
wpFinished: WizardForm.Color := WizardForm.FinishedPage.Color;
wpLicense: WizardForm.InnerPage.Color := clWhite;
wpSelectDir: WizardForm.InnerPage.Color := clWhite;
wpSelectTasks: WizardForm.TasksList.Color := clWhite;
wpReady: WizardForm.ReadyMemo.Color := clWhite
else
WizardForm.Color := clWhite;
end;
end;
It seems that the checklist box does not repaint completely, when the color changes.
But actually your code is too complicated (and actually not even correct). You can set the color of all components directly in InitializeWizard, instead of CurPageChanged. This way, the list box has the correct color, when painted for the first time already.
procedure InitializeWizard();
begin
WizardForm.Color := clWhite;
WizardForm.InnerPage.Color := WizardForm.Color;
WizardForm.TasksList.Color := WizardForm.Color;
WizardForm.ReadyMemo.Color := WizardForm.Color;
end;
Note that Inno Setup 6 has modern wizard style:
[Setup]
WizardStyle=modern
It looks like this:
I want make transparency under text here:
As you can see, I have black background what i don't want to have.
Greetings.
The PageNameLabel and PageDescriptionLabel are TNewStaticText components. This component does not support transparency. Though TLabel component, which has similar functionality otherwise, does support transparency (in Unicode version of Inno Setup and with themed Windows only).
So, you can replace those two components with TLabel equivalent. And then you need to make sure, that captions of your new custom components get updated, whenever Inno Setup does update the original components. For these two components, this is quite easy, as they get updated only, when a page changes. So you can update your custom components from CurPageChanged event function.
function CloneStaticTextToLabel(StaticText: TNewStaticText): TLabel;
begin
Result := TLabel.Create(WizardForm);
Result.Parent := StaticText.Parent;
Result.Left := StaticText.Left;
Result.Top := StaticText.Top;
Result.Width := StaticText.Width;
Result.Height := StaticText.Height;
Result.AutoSize := StaticText.AutoSize;
Result.ShowAccelChar := StaticText.ShowAccelChar;
Result.WordWrap := StaticText.WordWrap;
Result.Font := StaticText.Font;
StaticText.Visible := False;
end;
var
PageDescriptionLabel: TLabel;
PageNameLabel: TLabel;
procedure InitializeWizard();
begin
{ ... }
{ Create TLabel equivalent of standard TNewStaticText components }
PageNameLabel := CloneStaticTextToLabel(WizardForm.PageNameLabel);
PageDescriptionLabel := CloneStaticTextToLabel(WizardForm.PageDescriptionLabel);
end;
procedure CurPageChanged(CurPageID: Integer);
begin
{ Update the custom TLabel components from the standard hidden components }
PageDescriptionLabel.Caption := WizardForm.PageDescriptionLabel.Caption;
PageNameLabel.Caption := WizardForm.PageNameLabel.Caption;
end;
Way easier is to change original labels background color:
Inno Setup - Change size of page name and description labels
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?
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:
An alternative implementation that resizes the "pages" to cover whole upper parts of the wizard window:
Can you create a custom page that looks like the Finish page?
Displaying an image even over the "header":
How to hide the main panel and show an image over the whole page?
Displaying an image as a background of whole window: Inno Setup - Image as installer background.