Inno Setup insert a logo/image in between text - inno-setup

I have a custom welcome page sample mentioned below which I am trying to create. I need to insert a logo/image in between the text of a custom welcome page.
The sample code and RTF file is available in the below links:
[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program
OutputDir=userdocs:Inno Setup Examples Output
[Files]
Source: Welcome.rtf; Flags: dontcopy
[CustomMessages]
ISCustomPage1_Caption=Welcome to the Installation Wizard
ISCustomPage1_Description=This is a welcome page
[Code]
var
ISCustomPage1: TWizardPage;
RichEditViewer1: TRichEditViewer;
procedure InitializeWizard();
var
RtfName: string;
Rtf: AnsiString;
begin
{ Creates custom wizard page }
ISCustomPage1 :=
CreateCustomPage(
wpWelcome, CustomMessage('ISCustomPage1_Caption'),
CustomMessage('ISCustomPage1_Description'));
{ RichEditViewer1 }
RichEditViewer1 := TRichEditViewer.Create(WizardForm);
with RichEditViewer1 do
begin
Parent := ISCustomPage1.Surface;
Left := ScaleX(0);
Top := ScaleY(0);
Width := ScaleX(500);
Height := ScaleY(270);
ReadOnly := True;
ScrollBars := ssVertical;
RtfName := 'Welcome.rtf';
ExtractTemporaryFile(RtfName);
if LoadStringFromFile(ExpandConstant('{tmp}\' +RtfName), Rtf) then
begin
UseRichEdit := True;
RTFText := Rtf;
end;
end;
end;
https://pastebin.com/fxQQFsSN
https://filebin.ca/50kCnmRieWC0
Is there a way to achieve this?
Thanks in advance!

On possible way is to embed the image into RTF document.
For a similar question, see How to add clickable links to custom Inno Setup WelcomeLabel?
You will need Inno Setup 6.0.4 for this.
Or stack multiple labels and image controls.

Related

How to add a new page to Inno Setup OuterNotebook?

As part of an installer I'm working on using Inno Setup, I need to replicate the wpWelcome, page but with a different content. I've created a TNotebookPage, added the image, panel and content I want and it displays as expected. However I'm not sure how to add it to the WizardForm at the location I want. I can force it to appear as the first page, but clicking next/back shifts make the page disappear.
How do I insert the notebook page into the OuterNotebook at the relevant position?
function CreatePage: TNewNoteBookPage;
var
page: TNewNoteBookPage;
begin
page := TNewNoteBookPage.Create( WizardForm );
page.Notebook := WizardForm.OuterNotebook;
page.Align := alClient;
page.Color := clWindow;
page.Visible:= True;
Result := page;
end;
procedure InitializeWizard;
var
myPage: TNewNoteBookPage;
begin
WizardForm.OuterNotebook.ActivePage := WizardForm.WelcomePage;
myPage := CreatePage();
{ how do I specify where I want the page in the OuterNotebook? }
end;
In general, you specify a page position using TNewNotebookPage.PageIndex. But I'm afraid that by "manually" modifying the OuterNotebook you break an inner Inno Setup logic.
Why don't you just modify the existing Welcome page, instead of creating a new one?
See, for example, Custom Welcome and Finished page with stretched image in Inno Setup.
Alternatively, create a custom page on the InnerNotebook, but expand it to cover a whole window.
See How to hide the main panel and show an image over the whole page?
Martin's suggestions were very helpful, whilst not solving the problem directly they gave me an idea. I needed more than just a image covering the window. Hence my solution was to create a TNoteBookPage which I could format as needed and also a TWizardPage. Since the notebookpage couldn't be added to the installer without breaking inno-setup's ordering, I used the custom page to maintain ordering and when the CustomPage was set active, I switch the active page to be the notebook page hence showing what I needed.
[Code]
Apage, TWizardPage;
ANotebookPage: TNewNoteBookPage;
function CreatePage: TNewNoteBookPage;
var
page: TNewNoteBookPage;
sideBarImage: TBitmapImage;
panel: TPanel;
begin
{create page, sidebar and panel for our main content}
page := TNewNoteBookPage.Create( WizardForm );
page.Notebook := WizardForm.OuterNotebook;
page.Align := alClient;
page.Color := clWindow;
page.Visible:= True;
{ copies the already loaded sidebar image on the welcome page to this notebook page}
sideBarImage := TBitmapImage.Create( WizardForm );
sideBarImage.Bitmap := WizardForm.WizardBitmapImage.Bitmap;
sideBarImage.Top := WizardForm.WizardBitmapImage.Top;
sideBarImage.Left := WizardForm.WizardBitmapImage.Left;
sideBarImage.Width := WizardForm.WizardBitmapImage.Width;
sideBarImage.Height := WizardForm.WizardBitmapImage.Height;
sideBarImage.BackColor := WizardForm.WizardBitmapImage.BackColor;
sideBarImage.Parent := page;
panel := TPanel.Create( WizardForm );
panel.BevelOuter := bvNone;
panel.Color := clWindow;
panel.Parent := page;
panel.Left := sideBarImage.Width + ScaleX(10);
panel.Height := page.Height;
panel.Width := page.Width - sideBarImage.Width;
{ at this point we have a panel we can populate with content }
Result := page
end
procedure InitializeWizard;
begin
ANotebookPage := CreateOneClickInstallPage();
APage := CreateCustomPage( wpLicense, 'Install', '');
end
procedure CurPageChanged( CurPageID: Integer );
begin
WizardForm.Bevel1.Visible := true;
WizardForm.MainPanel.Visible := true;
WizardForm.InnerNotebook.Visible := true;
if CurPageID = APage.ID then begin
WizardForm.NextButton.Caption := SetupMessage(msgButtonInstall)
WizardForm.Bevel1.Visible := false;
WizardForm.MainPanel.Visible := false;
WizardForm.InnerNotebook.Visible := false;
WizardForm.OuterNotebook.ActivePage := ANoteBookPage;
end;
end

Avoid visual artifacts when initializing background (main) window

I try to change the default background image by my custom image.
I use this code:
procedure PrepareBackGround;
var
BackgroundBitmapImage: TBitmapImage;
TopLeftLabel: TLabel;
BitmapFileName: String;
sWidth,sHeight : integer;
begin
sWidth:=GetSystemMetrics(0);
sHeight:=GetSystemMetrics(1);
MainForm.Width := 848;
MainForm.height := 660;
MainForm.top := (sHeight-MainForm.height)/2;
MainForm.Left := (sWidth-MainForm.Width)/2;
BitmapFileName :=ExpandConstant('{src}\SetupFiles\FullScr.bmp');
BackgroundBitmapImage := TBitmapImage.Create(MainForm);
BackgroundBitmapImage.Bitmap.LoadFromFile(BitmapFileName);
BackgroundBitmapImage.Parent :=MainForm;
BackgroundBitmapImage.Align:=alCLient;
BackgroundBitmapImage.Stretch:=True;
TopLeftLabel := TLabel.Create(MainForm);
TopLeftLabel.Parent := MainForm;
TopLeftLabel.Left := 10;
TopLeftLabel.Top := 10 ;
TopLeftLabel.Font.Color := clBlack;
TopLeftLabel.color := clWhite;
TopLeftLabel.Font := WizardForm.WelcomeLabel1.Font;
TopLeftLabel.Font.Style := [fsitalic,fsBold];
TopLeftLabel.Caption :=
'SoftwareXXX ' +
GetIniString(
'Version Installation', 'Installation', 'unknown',
ExpandConstant('{src}\Sources\File.Ver'));
TopLeftLabel.WordWrap := WizardForm.WelcomeLabel1.WordWrap;
end;
procedure InitializeWizard;
begin
{ to display an image in background Window( see in Supportfunction.iss) }
PrepareBackGround;
{ ... }
end;
But when I run that, I see some lighting (as a flash). The reason of that light is the load of the new image.
How I can avoid this light? How can modify or access to the MainForm to modify the background image before it's displayed?
Thanks.
i can correct this falsh by :
[Setup]
WindowVisible=No
and i add at the end in my function
procedure PrepareBackGround;
var
//...
begin
//..
MainForm.Show;
end;
I believe the "flash", you refer to, is due to a resize of the maximized main window.
Try using WindowStartMaximized directive:
[Setup]
WindowStartMaximized=no
There's no event that is triggered before main window is shown, but after it is created.

How to create new About button in Inno Setup?

I want to create a new About button at the bottom left corner of all the pages like wpWelcome, wpSelectTasks, wpInstalling etc;
that will show some message if it is clicked. Message should close if user presses "OK". The button should show the full word "About" not like "Abou..."
I have checked CodeClasses.iss file in Inno Setup, but I could not understand which piece of code I should copy, which should not.
I have already seen these two post:
Adding a help button to an InnoSetup wizard page
INNO Setup: "About" button position
But they are not what I exactly want.
So please anyone help.
Here is a simplified, inlined version of the minimum code necessary to do what you've asked for:
[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program
[Code]
procedure AboutButtonOnClick(Sender: TObject);
begin
MsgBox('This is the about message!', mbInformation, mb_Ok);
end;
procedure InitializeWizard;
var
AboutButton: TNewButton;
begin
{ create an instance of the button and assign it to the local variable AboutButton }
AboutButton := TNewButton.Create(WizardForm);
{ set the parent to the just created button control }
AboutButton.Parent := WizardForm;
{ adjust the position to the created button control; it gets the horizontal indent }
{ by the right indent of the Cancel button; the vertical position as well as width }
{ and height are the same as the Cancel button has }
AboutButton.Left := WizardForm.ClientWidth - WizardForm.CancelButton.Left -
WizardForm.CancelButton.Width;
AboutButton.Top := WizardForm.CancelButton.Top;
AboutButton.Width := WizardForm.CancelButton.Width;
AboutButton.Height := WizardForm.CancelButton.Height;
{ set its caption }
AboutButton.Caption := '&About';
{ and assign the AboutButtonOnClick method to the OnClick event of the button }
AboutButton.OnClick := #AboutButtonOnClick;
end;

Customize content of finish page in InnoSetup

I would like to customize my finish page so I can have radio controls for user to choose what action to apply after finish page.
I tried various methods such as
Page1 := CreateCustomPage(wpInfoAfter, 'test', 'test');
and
Page1 := CreateCustomPage(wpFinished, 'test', 'test');
but none of them gives the result I want.
Any help would be appreciated, thanks!
For customization of the existing page you have to add to your ISS script something like that:
From-scratch code, not compiled:
procedure CurPageChanged(CurPageID: Integer);
var
MyMsg: TLabel;
begin
if (CurPageID <> wpFinished) then return;
MyMsg := TLabel.Create(WizardForm);
MyMsg.Parent := WizardForm.FinishedPage;
MyMsg.Caption := 'Hello World';
MyMsg.AutoSize := True;
end;
To correctly position your label you need to take into account pre-defined controls. Luckily, InnoSetup is open-source product https://github.com/jrsoftware/issrc
You can get a clue of what is contained on each wizard page via evaluating Wizard.pas and Wizard.dfm.txt files. So that, you'll be able to place correct MyMsg.Left and MyMsg.Top values.
If talking about "Custom page from scratch", it's much more complicated approach and again you'll need InnoSetup sources to guess what the system is expecting.
General idea:
constructor TWizardForm.Create(AOwner: TComponent);
begin
...
{ Initialize wpFinished page }
RegisterExistingPage(wpFinished, FinishedPage, nil, '', '');
SetFontNameSize(FinishedHeadingLabel.Font, LangOptions.WelcomeFontName,
LangOptions.WelcomeFontSize, '', 12);
FinishedHeadingLabel.Font.Style := [fsBold];
FinishedHeadingLabel.Caption := ExpandSetupMessage(msgFinishedHeadingLabel) + SNewLine;
AdjustLabelHeight(FinishedHeadingLabel);
FinishedLabel.Top := FinishedHeadingLabel.Top + FinishedHeadingLabel.Height;
YesRadio.Caption := SetupMessages[msgYesRadio];
NoRadio.Caption := SetupMessages[msgNoRadio];
RunList.MinItemHeight := ScalePixelsY(22);
...
end;

Inno Setup custom form is hiding beneath installation page

We are showing custom form during [Run] section in interactive installation. But custom form is hiding beneath installation page. Is any way to show the custom form on installer like message boxes.
Using below code to create custom form. and calling it in [Run] section.
[Setup]
AppId=Display Form
AppName=Display Form
DefaultDirname={sd}\Test
DisableDirPage=yes
WindowVisible=no
OutputDir=C:\Test
[Run]
Filename: C:\Test.exe; Flags: runhidden; AfterInstall : PassphraseForm;
[Code]
Procedure PassphraseForm();
var
Form: TSetupForm;
OKButton: TNewButton;
mLabel:TLabel;
LogFileString : AnsiString;
RichEditViewer: TRichEditViewer;
cancelclick: Boolean;
begin
Form := CreateCustomForm();
try
Form.ClientWidth := ScaleX(400);
Form.ClientHeight := ScaleY(180);
Form.Caption := 'Server';
Form.Center
mLabel:=TLabel.Create(Form);
mLabel.Caption:='';
mLabel.AutoSize:=True;
mLabel.Alignment:=taCenter;
OKButton := TNewButton.Create(Form);
OKButton.Parent := Form;
OKButton.Width := ScaleX(70);
OKButton.Height := ScaleY(30);
OKButton.Left := ScaleX(170);
OKButton.Top := ScaleY(142);
OKButton.Caption := 'OK';
OKButton.ModalResult := mrOk;
RichEditViewer :=TRichEditViewer.Create(Form);
RichEditViewer.Width :=360;
RichEditViewer.Height :=120;
RichEditViewer.Top := 20;
RichEditViewer.Left :=20;
RichEditViewer.Alignment:=taLeftJustify;
RichEditViewer.Parent := Form;
RichEditViewer.WordWrap :=True;
RichEditViewer.ScrollBars := ssBoth;
RichEditViewer.UseRichEdit := True;
RichEditViewer.Font.Size:=9;
RichEditViewer.RTFText := 'Server Value';
RichEditViewer.ReadOnly := True;
Form.ActiveControl := OKButton;
cancelclick:=True;
if Form.ShowModal() = mrOk then
begin
Log('Custom form is displayed succesfully');
end;
finally
Form.Free();
end;
end;
OK, this is really nice (undocumented) feature of Inno Setup!
I had no idea [Run] section support AfterInstall parameter (it is not mentioned in manual :)
Anyway your code works fine for me:
I think there is no way displaying the form below the main form as it is created as Modal form and shown with Form.ShowModal().
Are you sure the form is not displayed somewhere else? E.g. on second monitor/screen or outside of screen borders?
Also check the debugger - maybe a breakpoint was hit just when form is about to show and you need to press F9 to continue.

Resources