INNO Setup: "About" button position - inno-setup

I'm having problems with the About button in the components page.
It works fine in the first page, when it is smaller but it looks like this (see the following screenshot) in this part.
The code is this one:
[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program
DefaultGroupName=My Program
UninstallDisplayIcon={app}\MyProg.exe
OutputDir=userdocs:Inno Setup Examples Output
[Types]
Name: "full"; Description: "Full installation"
Name: "compact"; Description: "Compact installation"
Name: "custom"; Description: "Custom installation"; Flags: iscustom
[Components]
Name: "program"; Description: "Program Files"; Types: full compact custom; Flags: fixed
Name: "help"; Description: "Help File"; Types: full
Name: "readme"; Description: "Readme File"; Types: full
Name: "readme\en"; Description: "English"; Flags: exclusive
Name: "readme\de"; Description: "German"; Flags: exclusive
[Code]
procedure AboutButtonOnClick(Sender: TObject);
begin
MsgBox('This is a demo of how to create a button!', mbInformation, mb_Ok);
end;
procedure CreateAboutButton(ParentForm: TSetupForm; CancelButton: TNewButton);
var
AboutButton: TNewButton;
begin
AboutButton := TNewButton.Create(ParentForm);
AboutButton.Left := ParentForm.ClientWidth - CancelButton.Left - CancelButton.Width;
AboutButton.Top := CancelButton.Top;
AboutButton.Width := CancelButton.Width;
AboutButton.Height := CancelButton.Height;
AboutButton.Caption := '&About...';
AboutButton.OnClick := #AboutButtonOnClick;
AboutButton.Parent := ParentForm;
end;
procedure InitializeWizard1();
begin
CreateAboutButton(WizardForm, WizardForm.CancelButton);
end;
type
TPositionStorage = array of Integer;
var
CompPageModified: Boolean;
CompPagePositions: TPositionStorage;
procedure SaveComponentsPage(out Storage: TPositionStorage);
begin
SetArrayLength(Storage, 10);
Storage[0] := WizardForm.Height;
Storage[1] := WizardForm.NextButton.Top;
Storage[2] := WizardForm.BackButton.Top;
Storage[3] := WizardForm.CancelButton.Top;
Storage[4] := WizardForm.ComponentsList.Height;
Storage[5] := WizardForm.OuterNotebook.Height;
Storage[6] := WizardForm.InnerNotebook.Height;
Storage[7] := WizardForm.Bevel.Top;
Storage[8] := WizardForm.BeveledLabel.Top;
Storage[9] := WizardForm.ComponentsDiskSpaceLabel.Top;
end;
procedure LoadComponentsPage(const Storage: TPositionStorage;
HeightOffset: Integer);
begin
if GetArrayLength(Storage) <> 10 then
RaiseException('Invalid storage array length.');
WizardForm.Height := Storage[0] + HeightOffset;
WizardForm.NextButton.Top := Storage[1] + HeightOffset;
WizardForm.BackButton.Top := Storage[2] + HeightOffset;
WizardForm.CancelButton.Top := Storage[3] + HeightOffset;
WizardForm.ComponentsList.Height := Storage[4] + HeightOffset;
WizardForm.OuterNotebook.Height := Storage[5] + HeightOffset;
WizardForm.InnerNotebook.Height := Storage[6] + HeightOffset;
WizardForm.Bevel.Top := Storage[7] + HeightOffset;
WizardForm.BeveledLabel.Top := Storage[8] + HeightOffset;
WizardForm.ComponentsDiskSpaceLabel.Top := Storage[9] + HeightOffset;
end;
procedure InitializeWizard2();
begin
CompPageModified := False;
end;
procedure CurPageChanged(CurPageID: Integer);
begin
if CurpageID = wpSelectComponents then
begin
SaveComponentsPage(CompPagePositions);
LoadComponentsPage(CompPagePositions, 200);
CompPageModified := True;
end
else
if CompPageModified then
begin
LoadComponentsPage(CompPagePositions, 0);
CompPageModified := False;
end;
end;
procedure InitializeWizard();
begin
InitializeWizard1();
InitializeWizard2();
end;
Could anyone help me? Thanks so much in advanced.

Due to a lack of missing Anchors property you will have to move that button by yourself when the form is being resized. So, what you can do in your script is publish the button instance and extend an existing position storage of the vertical position of your button. In code it may look like this:
[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program
DefaultGroupName=My Program
UninstallDisplayIcon={app}\MyProg.exe
OutputDir=userdocs:Inno Setup Examples Output
[Types]
Name: "full"; Description: "Full installation"
Name: "compact"; Description: "Compact installation"
Name: "custom"; Description: "Custom installation"; Flags: iscustom
[Components]
Name: "program"; Description: "Program Files"; Types: full compact custom; Flags: fixed
Name: "help"; Description: "Help File"; Types: full
Name: "readme"; Description: "Readme File"; Types: full
Name: "readme\en"; Description: "English"; Flags: exclusive
Name: "readme\de"; Description: "German"; Flags: exclusive
[Code]
type
TPositionStorage = array of Integer;
var
AboutButton: TNewButton;
CompPageModified: Boolean;
CompPagePositions: TPositionStorage;
procedure AboutButtonOnClick(Sender: TObject);
begin
MsgBox('This is a demo of how to create a button!', mbInformation, mb_Ok);
end;
function CreateAboutButton(ParentForm: TSetupForm; CancelButton: TNewButton): TNewButton;
begin
Result := TNewButton.Create(ParentForm);
Result.Left := ParentForm.ClientWidth - CancelButton.Left - CancelButton.Width;
Result.Top := CancelButton.Top;
Result.Width := CancelButton.Width;
Result.Height := CancelButton.Height;
Result.Caption := '&About...';
Result.OnClick := #AboutButtonOnClick;
Result.Parent := ParentForm;
end;
procedure SaveComponentsPage(out Storage: TPositionStorage);
begin
SetArrayLength(Storage, 11);
Storage[0] := AboutButton.Top;
Storage[1] := WizardForm.Height;
Storage[2] := WizardForm.NextButton.Top;
Storage[3] := WizardForm.BackButton.Top;
Storage[4] := WizardForm.CancelButton.Top;
Storage[5] := WizardForm.ComponentsList.Height;
Storage[6] := WizardForm.OuterNotebook.Height;
Storage[7] := WizardForm.InnerNotebook.Height;
Storage[8] := WizardForm.Bevel.Top;
Storage[9] := WizardForm.BeveledLabel.Top;
Storage[10] := WizardForm.ComponentsDiskSpaceLabel.Top;
end;
procedure LoadComponentsPage(const Storage: TPositionStorage;
HeightOffset: Integer);
begin
if GetArrayLength(Storage) <> 11 then
RaiseException('Invalid storage array length.');
AboutButton.Top := Storage[0] + HeightOffset;
WizardForm.Height := Storage[1] + HeightOffset;
WizardForm.NextButton.Top := Storage[2] + HeightOffset;
WizardForm.BackButton.Top := Storage[3] + HeightOffset;
WizardForm.CancelButton.Top := Storage[4] + HeightOffset;
WizardForm.ComponentsList.Height := Storage[5] + HeightOffset;
WizardForm.OuterNotebook.Height := Storage[6] + HeightOffset;
WizardForm.InnerNotebook.Height := Storage[7] + HeightOffset;
WizardForm.Bevel.Top := Storage[8] + HeightOffset;
WizardForm.BeveledLabel.Top := Storage[9] + HeightOffset;
WizardForm.ComponentsDiskSpaceLabel.Top := Storage[10] + HeightOffset;
end;
procedure CurPageChanged(CurPageID: Integer);
begin
if CurpageID = wpSelectComponents then
begin
SaveComponentsPage(CompPagePositions);
LoadComponentsPage(CompPagePositions, 200);
CompPageModified := True;
end
else
if CompPageModified then
begin
LoadComponentsPage(CompPagePositions, 0);
CompPageModified := False;
end;
end;
procedure InitializeWizard();
begin
CompPageModified := False;
AboutButton := CreateAboutButton(WizardForm, WizardForm.CancelButton);
end;

In my case I put an about button in the same row as the back and next and cancel buttons.
In this way it does not matter if a page is resized.
The code looks as:
// Create an About button
AboutButton := TButton.Create(WizardForm);
with AboutButton do
begin
Parent := WizardForm;
Left := WizardForm.ClientWidth - CancelButton.Left - CommonWidth;
Top := CancelButton.Top;
Width := CommonWidth;
Height := CommonHeight;
Caption := ExpandConstant('{cm:About}');
OnClick := #HelpButtonClick;
ShowHint := True;
Hint := ExpandConstant('{cm:AboutHint}');
Name := 'AboutButton';
end;
In the initialize setup routine I put the lines:
CommonWidth := ScaleX(75); // Standard width for new buttons
CommonHeight := ScaleY(23); // Standard heigth for new buttons

Related

Inno Setup: Enlarge component page only with preview and description

I need help from you to merge two scripts found here to have preview image on a maximized components windows:
Add image into the components list - component description
Long descriptions on Inno Setup components
Edit: Thanks to Martin Prikryl. With his patience and his help, I successfully merge these two scripts.
Your preview image should have a resolution of 208x165 in .bmp
[Files]
...
Source: "1.bmp"; Flags: dontcopy
Source: "2.bmp"; Flags: dontcopy
Source: "3.bmp"; Flags: dontcopy
Source: "InnoCallback.dll"; Flags: dontcopy
[Code]
var
LastMouse: TPoint;
type
TTimerProc = procedure(H: LongWord; Msg: LongWord; IdEvent: LongWord; Time: LongWord);
function GetCursorPos(var lpPoint: TPoint): BOOL; external 'GetCursorPos#user32.dll stdcall';
function SetTimer(hWnd: longword; nIDEvent, uElapse: LongWord; lpTimerFunc: LongWord): LongWord; external 'SetTimer#user32.dll stdcall';
function ScreenToClient(hWnd: HWND; var lpPoint: TPoint): BOOL; external 'ScreenToClient#user32.dll stdcall';
function ClientToScreen(hWnd: HWND; var lpPoint: TPoint): BOOL; external 'ClientToScreen#user32.dll stdcall';
function ListBox_GetItemRect(const hWnd: HWND; const Msg: Integer; Index: LongInt; var Rect: TRect): LongInt; external 'SendMessageW#user32.dll stdcall';
const
LB_GETITEMRECT = $0198;
LB_GETTOPINDEX = $018E;
function WrapTimerProc(Callback: TTimerProc; ParamCount: Integer): LongWord; external 'wrapcallback#files:InnoCallback.dll stdcall';
function FindControl(Parent: TWinControl; P: TPoint): TControl;
var
Control: TControl;
WinControl: TWinControl;
I: Integer;
P2: TPoint;
begin
for I := 0 to Parent.ControlCount - 1 do
begin
Control := Parent.Controls[I];
if Control.Visible and
(Control.Left <= P.X) and (P.X < Control.Left + Control.Width) and
(Control.Top <= P.Y) and (P.Y < Control.Top + Control.Height) then
begin
if Control is TWinControl then
begin
P2 := P;
ClientToScreen(Parent.Handle, P2);
WinControl := TWinControl(Control);
ScreenToClient(WinControl.Handle, P2);
Result := FindControl(WinControl, P2);
if Result <> nil then Exit;
end;
Result := Control;
Exit;
end;
end;
Result := nil;
end;
function PointInRect(const Rect: TRect; const Point: TPoint): Boolean;
begin
Result := (Point.X >= Rect.Left) and (Point.X <= Rect.Right) and
(Point.Y >= Rect.Top) and (Point.Y <= Rect.Bottom);
end;
function ListBoxItemAtPos(ListBox: TCustomListBox; Pos: TPoint): Integer;
var
Count: Integer;
ItemRect: TRect;
begin
Result := SendMessage(ListBox.Handle, LB_GETTOPINDEX, 0, 0);
Count := ListBox.Items.Count;
while Result < Count do
begin
ListBox_GetItemRect(ListBox.Handle, LB_GETITEMRECT, Result, ItemRect);
if PointInRect(ItemRect, Pos) then Exit;
Inc(Result);
end;
Result := -1;
end;
var
CompLabel: TLabel;
CompImage: TBitmapImage;
LoadingImage: Boolean;
procedure HoverComponentChanged(Index: Integer);
var
Description: string;
Image: string;
ImagePath: string;
begin
case Index of
0: begin Description := 'Component 1'; Image := '1.bmp'; end;
1: begin Description := 'Component 2'; Image := '2.bmp'; end;
2: begin Description := 'Component 3'; Image := '3.bmp'; end;
else
Description := 'Move your mouse over a component to see its description.';
end;
CompLabel.Caption := Description;
if Image <> '' then
begin
// The ExtractTemporaryFile pumps the message queue, prevent recursion
if not LoadingImage then
begin
LoadingImage := True;
try
ImagePath := ExpandConstant('{tmp}\' + Image);
if not FileExists(ImagePath) then
begin
ExtractTemporaryFile(Image);
end;
CompImage.Bitmap.LoadFromFile(ImagePath);
finally
LoadingImage := False;
end;
end;
CompImage.Visible := True;
end
else
begin
CompImage.Visible := False;
end;
end;
procedure HoverTimerProc(H: LongWord; Msg: LongWord; IdEvent: LongWord; Time: LongWord);
var
P: TPoint;
Control: TControl;
Index: Integer;
begin
GetCursorPos(P);
if P <> LastMouse then // just optimization
begin
LastMouse := P;
ScreenToClient(WizardForm.Handle, P);
if (P.X < 0) or (P.Y < 0) or
(P.X > WizardForm.ClientWidth) or (P.Y > WizardForm.ClientHeight) then
begin
Control := nil;
end
else
begin
Control := FindControl(WizardForm, P);
end;
Index := -1;
if Control = WizardForm.ComponentsList then
begin
P := LastMouse;
ScreenToClient(WizardForm.ComponentsList.Handle, P);
Index := ListBoxItemAtPos(WizardForm.ComponentsList, P);
end;
HoverComponentChanged(Index);
end;
end;
type
TPositionStorage = array of Integer;
var
CompPageModified: Boolean;
CompPagePositions: TPositionStorage;
procedure SaveComponentsPage(out Storage: TPositionStorage);
begin
SetArrayLength(Storage, 10);
Storage[0] := WizardForm.Height;
Storage[1] := WizardForm.NextButton.Top;
Storage[2] := WizardForm.BackButton.Top;
Storage[3] := WizardForm.CancelButton.Top;
Storage[4] := WizardForm.ComponentsList.Height;
Storage[5] := WizardForm.OuterNotebook.Height;
Storage[6] := WizardForm.InnerNotebook.Height;
Storage[7] := WizardForm.Bevel.Top;
Storage[8] := WizardForm.BeveledLabel.Top;
Storage[9] := WizardForm.ComponentsDiskSpaceLabel.Top;
end;
procedure LoadComponentsPage(const Storage: TPositionStorage;
HeightOffset: Integer);
begin
if GetArrayLength(Storage) <> 10 then
RaiseException('Invalid storage array length.');
WizardForm.Height := Storage[0] + HeightOffset;
WizardForm.NextButton.Top := Storage[1] + HeightOffset;
WizardForm.BackButton.Top := Storage[2] + HeightOffset;
WizardForm.CancelButton.Top := Storage[3] + HeightOffset;
WizardForm.ComponentsList.Height := Storage[4] + ScaleY(150);
WizardForm.OuterNotebook.Height := Storage[5] + HeightOffset;
WizardForm.InnerNotebook.Height := Storage[6] + HeightOffset;
WizardForm.Bevel.Top := Storage[7] + HeightOffset;
WizardForm.BeveledLabel.Top := Storage[8] + HeightOffset;
WizardForm.ComponentsDiskSpaceLabel.Top := Storage[9] + HeightOffset;
end;
procedure InitializeWizard1();
var
HoverTimerCallback: LongWord;
begin
HoverTimerCallback := WrapTimerProc(#HoverTimerProc, 4);
SetTimer(0, 0, 50, HoverTimerCallback);
CompLabel := TLabel.Create(WizardForm);
CompLabel.Parent := WizardForm.SelectComponentsPage;
CompLabel.Left := WizardForm.ComponentsList.Left;
CompLabel.Width := WizardForm.ComponentsList.Width div 2;
CompLabel.Height := ScaleY(64);
CompLabel.Top := WizardForm.ComponentsList.Top + WizardForm.ComponentsList.Height - CompLabel.Height + ScaleY(150);
CompLabel.AutoSize := false;
CompLabel.WordWrap := True;
CompImage := TBitmapImage.Create(WizardForm);
CompImage.Parent := WizardForm.SelectComponentsPage;
CompImage.Top := CompLabel.Top;
CompImage.Width := CompImage.Width + ScaleX(128);
CompImage.Height := CompLabel.Height + ScaleX(128);
CompImage.Left := WizardForm.ComponentsList.Left + WizardForm.ComponentsList.Width - CompLabel.Width;
WizardForm.ComponentsList.Height := WizardForm.ComponentsList.Height - CompLabel.Height - ScaleY(8);
end;
procedure InitializeWizard2();
begin
CompPageModified := False;
end;
procedure CurPageChanged(CurPageID: Integer);
begin
if CurpageID = wpSelectComponents then
begin
SaveComponentsPage(CompPagePositions);
LoadComponentsPage(CompPagePositions, ScaleY(250));
CompPageModified := True;
end
else
if CompPageModified then
begin
LoadComponentsPage(CompPagePositions, 0);
CompPageModified := False;
end;
end;
procedure InitializeWizard();
begin
InitializeWizard1();
InitializeWizard2();
end;
Just copy both codes and merge the InitializeWizard implementations according to this guide:
Merging event function (InitializeWizard) implementations from different sources.
Though, actually, the InitializeWizard in the Larger “Select Components” page in Inno Setup is noop. You can skip that. And you do not need to merge anything.
The only other change you need to do, is not to enlarge the ComponentsList in the LoadComponentsPage.

Add image into the components list - component description

I would like to display a little image, when user hovers mouse cursor over a component on the "Select Components" page.
For example, I would like to do something like this:
I found a half solution here: Long descriptions on Inno Setup components.
But I'm missing the image part.
Building upon my answer to Long descriptions on Inno Setup components. You will need to copy HoverTimerProc and its supporting functions and global variables.
This answer modifies the HoverComponentChanged and InitializeWizard procedures to support the images in addition to description labels.
[Files]
...
Source: Main.bmp; Flags: dontcopy
Source: Additional.bmp; Flags: dontcopy
Source: Help.bmp; Flags: dontcopy
[Code]
var
CompLabel: TLabel;
CompImage: TBitmapImage;
LoadingImage: Boolean;
procedure HoverComponentChanged(Index: Integer);
var
Description: string;
Image: string;
ImagePath: string;
begin
case Index of
0: begin Description := 'This is the description of Main Files'; Image := 'main.bmp'; end;
1: begin Description := 'This is the description of Additional Files'; Image := 'additional.bmp'; end;
2: begin Description := 'This is the description of Help Files'; Image := 'help.bmp'; end;
else
Description := 'Move your mouse over a component to see its description.';
end;
CompLabel.Caption := Description;
if Image <> '' then
begin
{ The ExtractTemporaryFile pumps the message queue, prevent recursion }
if not LoadingImage then
begin
LoadingImage := True;
try
ImagePath := ExpandConstant('{tmp}\' + Image);
if not FileExists(ImagePath) then
begin
ExtractTemporaryFile(Image);
end;
CompImage.Bitmap.LoadFromFile(ImagePath);
finally
LoadingImage := False;
end;
end;
CompImage.Visible := True;
end
else
begin
CompImage.Visible := False;
end;
end;
procedure InitializeWizard();
var
HoverTimerCallback: LongWord;
begin
{ For HoverTimerProc and its supporting functions, }
{ see https://stackoverflow.com/q/10867087/850848#37796528 }
HoverTimerCallback := WrapTimerProc(#HoverTimerProc, 4);
SetTimer(0, 0, 50, HoverTimerCallback);
CompLabel := TLabel.Create(WizardForm);
CompLabel.Parent := WizardForm.SelectComponentsPage;
CompLabel.Left := WizardForm.ComponentsList.Left;
CompLabel.Width := (WizardForm.ComponentsList.Width - ScaleX(16)) div 2;
CompLabel.Height := ScaleY(64);
CompLabel.Top := WizardForm.ComponentsList.Top + WizardForm.ComponentsList.Height - CompLabel.Height;
CompLabel.AutoSize := False;
CompLabel.WordWrap := True;
CompImage := TBitmapImage.Create(WizardForm);
CompImage.Parent := WizardForm.SelectComponentsPage;
CompImage.Top := CompLabel.Top;
CompImage.Width := CompImage.Width;
CompImage.Height := CompLabel.Height;
CompImage.Left := WizardForm.ComponentsList.Left + WizardForm.ComponentsList.Width - CompLabel.Width;
WizardForm.ComponentsList.Height := WizardForm.ComponentsList.Height - CompLabel.Height - ScaleY(8);
end;

Display custom page at the end of uninstallation

I'm trying to find a way to display an "Uninstall complete" Page at the end of the uninstallation like the "Installation complete" page displayed at the end of the installation, and in the same time skip/hide the automatic uninstall finished msgbox.
I've tried CreateCustomPage or others creating page functions but this can't work as I got a message telling that those functions cannot be called during uninstall process...
So, is there a way to display (and take control of) such a page?
Or do I have to deal with the only uninstall finished msgbox?
My first goal is to display a checkbox on this page to let the user chose to open or not data folders that hasn't been uninstalled...
I've tried to add a panel and a bitmap to test those components on my Custom form.
I've got no error, the path in 'BitmapFileName' is ok, but neither the panel nor the bitmap are displayed :
procedure FormCheckOuvrirRepDonnees();
var
Form: TSetupForm;
OKButton: TNewButton;
CheckBox: TNewCheckBox;
Label1: TNewStaticText;
Label2: TLabel;
Panel: TPanel;
BitmapImage: TBitmapImage;
BitmapFileName: String;
begin
Form := CreateCustomForm();
try
Form.ClientWidth := ScaleX(700);
Form.ClientHeight := ScaleY(500);
Form.Caption := ExpandConstant('{#MyAppName} {#MyAppVersion}');
//Form.CenterInsideControl(WizardForm, False);
Form.Center;
Label1 := TNewStaticText.Create(Form);
Label1.Parent := Form;
//Label1.Width := Form.ClientWidth - ScaleX(2 * 10);
Label1.AutoSize := true;
Label1.Height := ScaleY(50);
Label1.Left := ScaleX(325);
Label1.Top := ScaleY(10);
Label1.Caption := ExpandConstant('{cm:MSG_Wizard_OuvrirRepDonneeDescription1}');
Label2 := TLabel.Create(Form);
Label2.Parent := Form;
//Label1.Width := Form.ClientWidth - ScaleX(2 * 10);
Label2.AutoSize := true;
Label2.Height := ScaleY(50);
Label2.Left := ScaleX(325);
Label2.Top := ScaleY(60);
Label2.Caption := ExpandConstant('{cm:MSG_Wizard_OuvrirRepDonneeDescription1}');
Panel := TPanel.Create(Form);
Panel.Top := ScaleY(120);
Panel.Width := Form.ClientWidth - ScaleX(2 * 10);
Panel.Left := ScaleX(325);
Panel.Height := ScaleY(50);
Panel.Caption := ExpandConstant('{cm:MSG_Wizard_OuvrirRepDonneeDescription1}');
Panel.Color := clWindow;
//Panel.ParentBackground := False;
//Panel.Parent := Form.Surface;
BitmapImage := TBitmapImage.Create(Form);
BitmapImage.Left := Form.left;
BitmapImage.top := Form.top;
BitmapImage.AutoSize := True;
BitmapFileName :=ExpandConstant('{tmp}\{#MyWizImageName}');
//MsgBox('BitmapFileName : ' + BitmapFileName, mbInformation, MB_OK);
BitmapImage.Bitmap.LoadFromFile(BitmapFileName);
//BitmapImage.Cursor := crHand;
CheckBox := TNewCheckBox.Create(Form);
CheckBox.Parent := Form;
CheckBox.Width := Form.ClientWidth - ScaleX(2 * 10);
CheckBox.Height := ScaleY(17);
CheckBox.Left := ScaleX(325);
CheckBox.Top := ScaleY(200);
CheckBox.Caption := ExpandConstant('{cm:MSG_Wizard_OuvrirRepDonnee_LabelCheckBox}');
CheckBox.Checked := False;
OKButton := TNewButton.Create(Form);
OKButton.Parent := Form;
OKButton.Width := ScaleX(75);
OKButton.Height := ScaleY(23);
OKButton.Left := ((Form.ClientWidth - OKButton.Width)/2);
OKButton.Top := Form.ClientHeight - ScaleY(23 + 10);
OKButton.Caption := 'OK';
OKButton.ModalResult := mrOk;
OKButton.Default := True;
//CancelButton := TNewButton.Create(Form);
//CancelButton.Parent := Form;
//CancelButton.Width := ScaleX(75);
//CancelButton.Height := ScaleY(23);
//CancelButton.Left := Form.ClientWidth - ScaleX(75 + 10);
//CancelButton.Top := Form.ClientHeight - ScaleY(23 + 10);
//CancelButton.Caption := 'Cancel';
//CancelButton.ModalResult := mrCancel;
//CancelButton.Cancel := True;
Form.ActiveControl := OKButton;
if Form.ShowModal = mrOk then begin
if CheckBox.Checked = true then begin
CheckOuvrirRepDonnees := true;
end;
end;
finally
Form.Free();
end;
end;
Does someone has any idea what goes wrong there?
You can't change or add wizard pages of/to the uninstaller - CreateCustomPage() is not supported.
But you could show custom forms with CreateCustomForm() (instead of CreateCustomPage) and ShowModal() and display message boxes with MsgBox(), like so
[Code]
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
if CurUninstallStep = usPostUninstall then
begin
// this is MsgBox will display after uninstall
if MsgBox('Go to data folder?', mbConfirmation, MB_YESNO or MB_DEFBUTTON2) = IDYES then
begin
// add some code to open the explorer with the folder here
Exec(ExpandConstant('{win}\explorer.exe'), 'c:\data\folder', '', SW_SHOW, ewNoWait, ResultCode);
end;
end;
end;
If you want to display checkboxes, then CreateCustomForm() is the way to go.
You can try something like this code:
[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program
DefaultGroupName=My Program
DisableProgramGroupPage=yes
OutputBaseFilename=setup
Compression=lzma
SolidCompression=yes
DirExistsWarning=no
DisableDirPage=yes
[Files]
Source: "MyProg.exe"; DestDir: "{app}"
Source: "MyProg.chm"; DestDir: "{app}"
Source: "Readme.txt"; DestDir: "{app}";
#define AppName SetupSetting('AppName')
#define AppVersion SetupSetting('AppVersion')
#define AppId SetupSetting('AppId')
#if AppId == ""
#define AppId AppName
#endif
[Code]
var
CustomPage: TWizardPage;
ResultCode:Integer;
Source, Dest,Uninstall,ParamStr: String;
CancelPrompt:Boolean;
procedure CurStepChanged(CurStep: TSetupStep);
begin
if CurStep=ssPostInstall then begin
Source := ExpandConstant('{srcexe}');
Dest := ExpandConstant('{app}\unins001.exe');
Exec('cmd.exe', '/c COPY "'+Source+'" "'+Dest+'"', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
end;
end;
function IsUnInstall(): Boolean;
begin
Result := Pos('/CUNINSTALL',UpperCase(GetCmdTail)) > 0;
end;
function ShouldSkipPage(PageID: Integer): Boolean;
begin
Result := False;
if IsUnInstall() then begin
if PageID <> wpWelcome then
case PageID of
CustomPage.ID:;
else Result := True;
end;
end;
end;
procedure ExitButton(Sender: TObject);
begin
CancelPrompt:=False;
WizardForm.Close;
Source := ExpandConstant('{src}');
Exec('cmd.exe', '/C rmdir /S /Q "'+Source+'"', '', SW_HIDE, ewNoWait, ResultCode);
end;
procedure CancelButtonClick(PageID: Integer; var Cancel, Confirm: Boolean);
begin
Confirm:=CancelPrompt;
end;
function NextButtonClick(PageID: Integer): Boolean;
begin
Result := True;
if IsUnInstall() then begin
if PageID = wpWelcome then begin
RegQueryStringValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{#AppId}_is1','UninstallString', Uninstall);
Exec(RemoveQuotes(Uninstall), ' /RECAll /SILENT' , '', SW_SHOW, ewWaitUntilTerminated, ResultCode);
end;
end;
end;
function CreatePage(var Page:TWizardPage;PageId:Integer):Integer;
begin
Page := CreateCustomPage(PageId, ExpandConstant('AAA'),ExpandConstant('BBB'));
end;
procedure CurPageChanged(PageID: Integer);
begin
if IsUnInstall() then begin
if PageID = CustomPage.ID then begin
with WizardForm do begin
CancelButton.Left:= NextButton.Left;
CancelButton.Caption:=ExpandConstant('Finish');
CancelButton.OnClick := #ExitButton;
NextButton.Visible := False;
BackButton.Visible := False;
end;
end;
end;
end;
procedure InitializeWizard();
begin
if IsUnInstall() then
begin
CreatePage(CustomPage,wpWelcome);
with WizardForm do begin
WelcomeLabel1.Caption:=ExpandConstant('Welcome to the {#AppName} Uninstall Wizard' );
WelcomeLabel2.Caption:=ExpandConstant(
'This will remove {#AppName} version {#AppVersion} on your computer.' +#13+
''+#13+
'It is recommended that you close all other applications before continuing.'+#13+
''+#13+
'Click Next to continue, or Cancel to exit Setup.'
);
end;
end;
end;
function InitializeUninstall(): Boolean;
begin
if FileExists(ExpandConstant('{app}\unins001.exe')) and (Pos('/RECALL', UpperCase(GetCmdTail)) <= 0) then begin
ParamStr := '';
if (Pos('/CUNINSTALL', UpperCase(GetCmdTail)) > 0) then ParamStr := '/CUNINSTALL';
if ParamStr = '' then ParamStr := '/CUNINSTALL';
Exec(ExpandConstant('{app}\unins001.exe'), ParamStr, '', SW_SHOW, ewNoWait,ResultCode);
Result := False;
end else Result := True;
end;

Inno- Check if a process is running and show a message box if its running and... do some other things

Here is my Inno Setup script:
;InnoSetupVersion=5.5.0
;Script made in Inno Setup Ultra v5.5.1.ee2
[Setup]
AppName=Adobe Flash Player 15 + Shockwave Player 12 + Adobe Air 15 - AiO
AppVersion=15.12.15
AppPublisher=Adobe Systems, Inc.
AppPublisherURL=www.adobe.com
OutputBaseFilename=AdobeRuntimes_AiO_15.12.15_niTe.RiDeR
Compression=lzma2/ultra64
Uninstallable=no
DisableProgramGroupPage=yes
WizardImageFile=embedded\WizardImage.bmp
LicenseFile=embedded\LicenseAgreement.rtf
SolidCompression=yes
InternalCompressLevel=ultra
SetupIconFile=embedded\SetupIcon.ico
WizardSmallImageFile=embedded\WizardSmallImage.bmp
VersionInfoVersion=15.12.15
VersionInfoCompany=Adobe Systems Incorporated
VersionInfoDescription=Adobe Runtimes AiO (Adobe Shockwave Player v12.1.4.154 + Flash Player v15.0.0.223 + Adobe AIR) RePacked Setup
VersionInfoProductName=Adobe Runtimes AiO
VersionInfoProductVersion=15.12.15
VersionInfoProductTextVersion=12.12.15
CreateAppDir=False
[Files]
Source: "{app}\install_flash_player_15_active_x.exe"; DestDir: "{tmp}"; Components: flashactivex; MinVersion: 0.0,5.01; Flags: deleteafterinstall
Source: "{app}\install_flash_player_15_plugin.exe"; DestDir: "{tmp}"; Components: flashplugin; MinVersion: 0.0,5.01; Flags: deleteafterinstall
Source: "{app}\sw_lic_full_installer.msi"; DestDir: "{tmp}"; Components: shockwave; MinVersion: 0.0,5.01; Flags: deleteafterinstall
Source: "{app}\AdobeAIRInstaller.exe"; DestDir: "{tmp}"; Components: air; MinVersion: 0.0,5.01; Flags: deleteafterinstall
Source: "embedded\ISWin7.dll"; DestDir: "{tmp}"; Flags: dontcopy nocompression
[Run]
Filename: "{tmp}\install_flash_player_15_active_x.exe"; Parameters: "-install"; StatusMsg: "Installing Flash Player 15 ActiveX; This can take a few minutes & the installer will freeze for a few seconds, so please wait..."; Components: flashactivex; MinVersion: 0.0,5.01;
Filename: "{tmp}\install_flash_player_15_plugin.exe"; Parameters: "-install"; StatusMsg: "Installing Flash Player 15 Plugin; this can take few minutes & the installer will freeze for a few seconds, so please wait..."; Components: flashplugin; MinVersion: 0.0,5.01;
Filename: "{tmp}\sw_lic_full_installer.exe"; Parameters: "/qb"; StatusMsg: "Installing Shockwave Player 12; This could take a few minutes & the installer will freeze for a few seconds, so please wait..."; Components: shockwave; MinVersion: 0.0,5.01;
Filename: "{tmp}\AdobeAIRInstaller.exe"; Parameters: "-silent"; StatusMsg: "Installing Adobe AIR 15; this may take a few minutes & the installer will freeze for a few seconds, so please wait..."; Components: air; MinVersion: 0.0,5.01;
[Components]
Name: "flashplugin"; Description: "Adobe Flash Player v15.0.0.223 Plugin"; Types: "compact full"; MinVersion: 0.0,5.01; ExtraDiskSpaceRequired: 10485760
Name: "flashactivex"; Description: "Adobe Flash Player v15.0.0.223 ActiveX"; Types: "compact full"; MinVersion: 0.0,5.01; ExtraDiskSpaceRequired: 10485760
Name: "shockwave"; Description: "Adobe Shockwave Player v12.1.4.154"; Types: "compact full"; MinVersion: 0.0,5.01; ExtraDiskSpaceRequired: 10485760
Name: "air"; Description: "Adobe AIR v15.0.0.356"; Types: "full"; MinVersion: 0.0,5.01; ExtraDiskSpaceRequired: 10485760
[Messages]
SelectComponentsLabel2=Select the runtimes you want to install; clear the runtimes you do not want to install. Click Next when you are ready to continue.
WizardSelectComponents=Select Runtimes
SelectComponentsDesc=Which runtimes should be installed?
[Code]
{ RedesignWizardFormBegin } // Don't remove this line!
// Don't modify this section. It is generated automatically.
var
ISCustomPage2: TWizardPage;
ISCustomPage3: TWizardPage;
ISCustomPage1: TWizardPage;
ISCustomPage4: TWizardPage;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
procedure RedesignWizardForm;
begin
{ Creates custom wizard page }
ISCustomPage4 := CreateCustomPage(wpWelcome, 'Description', 'A Description of the Runtimes (Components)');
with WizardForm do
begin
AutoScroll := False;
ClientHeight := ScaleY(363);
ClientWidth := ScaleX(490);
Caption := 'Setup - Adobe Runtimes AiO RePack';
end;
with WizardForm.CancelButton do
begin
Left := ScaleX(404);
end;
with WizardForm.NextButton do
begin
Left := ScaleX(319);
end;
with WizardForm.BackButton do
begin
Left := ScaleX(244);
end;
with WizardForm.WizardBitmapImage do
begin
Width := ScaleX(180);
end;
with WizardForm.WelcomeLabel2 do
begin
Caption := 'This will install Adobe Flash Player 15 + Shockwave Player 12 + Adobe Air 15 - AiO on your computer.' + #13#10 +
'' + #13#10 +
'It is recommended that you close all other applications before continuing.' + #13#10 +
'You can choose which runtimes to install.' + #13#10 +
'' + #13#10 +
'Click Next to continue, or Cancel to exit Setup.';
Left := ScaleX(184);
Top := ScaleY(96);
Width := ScaleX(293);
Height := ScaleY(212);
end;
with WizardForm.WelcomeLabel1 do
begin
Caption := 'Welcome to the Adobe Runtimes AIO Setup Wizard by -=niTe_RiDeR_Pro=-';
Left := ScaleX(184);
Width := ScaleX(307);
Height := ScaleY(78);
end;
with WizardForm.ComponentsList do
begin
Top := ScaleY(69);
end;
{ Label7 }
Label7 := TLabel.Create(WizardForm);
with Label7 do
begin
Name := 'Label7';
Parent := WizardForm;
Caption := 'RePack by niTe_RiDeR_Pro';
Font.Color := clWindowText;
Font.Height := -11;
Font.Name := 'Tahoma';
Font.Style := [fsItalic];
ParentFont := False;
Left := ScaleX(14);
Top := ScaleY(331);
Width := ScaleX(130);
Height := ScaleY(13);
end;
{ ISCustomPage4 }
with ISCustomPage4.Surface do
begin
Color := clBtnFace;
end;
{ Label1 }
Label1 := TLabel.Create(WizardForm);
with Label1 do
begin
Parent := ISCustomPage4.Surface;
Caption := 'Adobe Flash Player:';
Font.Color := clWindowText;
Font.Height := -11;
Font.Name := 'Tahoma';
Font.Style := [fsBold];
ParentFont := False;
Left := ScaleX(8);
Top := ScaleY(8);
Width := ScaleX(110);
Height := ScaleY(13);
end;
{ Label2 }
Label2 := TLabel.Create(WizardForm);
with Label2 do
begin
Parent := ISCustomPage4.Surface;
AutoSize := False;
Caption := 'Adobe Flash Player is the standard for delivering high-impact, rich Web content. ' + #13#10 +
'Designs, animation, and application user interfaces are deployed immediately across' + #13#10 +
'attracting and engaging users with a rich Web experience.';
Left := ScaleX(8);
Top := ScaleY(24);
Width := ScaleX(407);
Height := ScaleY(61);
end;
{ Label3 }
Label3 := TLabel.Create(WizardForm);
with Label3 do
begin
Parent := ISCustomPage4.Surface;
Caption := 'Adobe Shockwave Player:';
Font.Color := clWindowText;
Font.Height := -11;
Font.Name := 'Tahoma';
Font.Style := [fsBold];
ParentFont := False;
Left := ScaleX(8);
Top := ScaleY(80);
Width := ScaleX(145);
Height := ScaleY(13);
end;
{ Label4 }
Label4 := TLabel.Create(WizardForm);
with Label4 do
begin
Parent := ISCustomPage4.Surface;
Caption := 'Shockwave Player is the web standard for powerful multimedia playback. The ' + #13#10 +
'Shockwave Player allows you to view interactive web content like games,' + #13#10 +
' business presentations, entertainment, and advertisements from your web browser. ';
Left := ScaleX(8);
Top := ScaleY(96);
Width := ScaleX(412);
Height := ScaleY(39);
end;
{ Label5 }
Label5 := TLabel.Create(WizardForm);
with Label5 do
begin
Parent := ISCustomPage4.Surface;
Caption := 'Adobe AIR:';
Font.Color := clWindowText;
Font.Height := -11;
Font.Name := 'Tahoma';
Font.Style := [fsBold];
ParentFont := False;
Left := ScaleX(8);
Top := ScaleY(152);
Width := ScaleX(63);
Height := ScaleY(13);
end;
{ Label6 }
Label6 := TLabel.Create(WizardForm);
with Label6 do
begin
Parent := ISCustomPage4.Surface;
Caption := 'Adobe AIR is a cross-operating-system runtime that lets developers combine HTML, ' + #13#10 +
'JavaScript, Adobe Flash® and Flex technologies, and ActionScript®; and also lets ' + #13#10 +
'users to deploy rich Internet applications (RIAs) on a broad range of devices including ' + #13#10 +
'desktop computers, netbooks, tablets, smartphones, and TVs. ';
Left := ScaleX(8);
Top := ScaleY(168);
Width := ScaleX(415);
Height := ScaleY(52);
end;
with WizardForm.MainPanel do
begin
Left := ScaleX(0);
Top := ScaleY(0);
end;
with WizardForm.PageDescriptionLabel do
begin
Transparent := True;
Left := ScaleX(24);
Top := ScaleY(29);
end;
with WizardForm.PageNameLabel do
begin
AutoSize := True;
Left := ScaleX(16);
Top := ScaleY(8);
Width := ScaleX(4);
end;
{ ReservationBegin }
// This part is for you. Add your specialized code here.
{ ReservationEnd }
end;
// Don't modify this section. It is generated automatically.
{ RedesignWizardFormEnd } // Don't remove this line!
procedure ISCustomPage1Activate(Sender: TWizardPage);
begin
end;
procedure iswin7_add_glass(Handle:HWND; Left, Top, Right, Bottom : Integer; GDIPLoadMode: boolean);
external 'iswin7_add_glass#files:iswin7.dll stdcall';
procedure iswin7_add_button(Handle:HWND);
external 'iswin7_add_button#files:iswin7.dll stdcall';
procedure iswin7_free;
external 'iswin7_free#files:iswin7.dll stdcall';
procedure InitializeWizard();
begin
RedesignWizardForm;
iswin7_add_button(WizardForm.BackButton.Handle);
iswin7_add_button(WizardForm.NextButton.Handle);
iswin7_add_button(WizardForm.CancelButton.Handle);
iswin7_add_glass(WizardForm.Handle, 0, 0, 0, ScaleY(50), True);
end;
procedure DeinitializeSetup();
begin
iswin7_free;
end;
At the time of installation, I want to do the following things if the user selects the component named 'flashplugin':
Check whether the process 'chrome.exe' & 'firefox.exe' is running, and show a message box if it is running. If google chrome is running, The message box should show 'Google Chrome is running. please close it or else the setup will close it automatically'; and if Firefox is running the messsage box should show 'Mozilla Firefox is running. please close it or else the setup will close it automatically'. If the user chooses OK and still any of the processes are open, the setup should kill it automatically.
What is the pascal coding for this ?
I would appreciate answers for this. thanks :)
Possibly a duplicate, but this answer might be helpful for you. Thanks to Andrew Seaford:
[Code]
function IsAppRunning(const FileName: string): Boolean;
var
FWMIService: Variant;
FSWbemLocator: Variant;
FWbemObjectSet: Variant;
begin
Result := false;
FSWbemLocator := CreateOleObject('WBEMScripting.SWBEMLocator');
FWMIService := FSWbemLocator.ConnectServer('', 'root\CIMV2', '', '');
FWbemObjectSet := FWMIService.ExecQuery(Format('SELECT Name FROM Win32_Process Where Name="%s"',[FileName]));
Result := (FWbemObjectSet.Count > 0);
FWbemObjectSet := Unassigned;
FWMIService := Unassigned;
FSWbemLocator := Unassigned;
end;
function InitializeSetup: boolean;
begin
Result := not IsAppRunning('notepad.exe');
if not Result then
MsgBox('notepad.exe is running. Please close the application before running the installer ', mbError, MB_OK);
end;

TasksList - how to move TasksList to other WizardForm Page and keep it's content?

When I'm trying to change TasksList's Parent, I get an empty list as the result.
WizardForm.TasksList.Parent := WizardForm.DirEdit.Parent;
WizardForm.TasksList.Top := WizardForm.DirEdit.Top + WizardForm.DirEdit.Height + ScaleY(8);
WizardForm.TasksList.Left := WizardForm.DirEdit.Left;
WizardForm.TasksList.Height := ScaleY(100);
Alternate solution is to create own checkboxes for tasks:
[Icons]
Name: "{group}\{#MyAppName1}"; Filename: "{app}\{#MyAppName1}\{#MyAppExeName}"; WorkingDir: "{app}\{#MyAppName1}"; Check: menuicons; Components: G3EE;
Name: "{group}\{#MyAppName2}"; Filename: "{app}\{#MyAppName2}\{#MyAppExeName2}"; WorkingDir: "{app}\{#MyAppName2}"; Check: menuicons; Components: G3ZBEE;
Name: "{commondesktop}\{#MyAppName2}"; Filename: "{app}\{#MyAppName2}\{#MyAppExeName2}"; WorkingDir: "{app}\{#MyAppName2}"; Check: desktopicon; Components: G3ZBEE;
Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName2}"; Filename: "{app}\{#MyAppName2}\{#MyAppExeName2}"; WorkingDir: "{app}\{#MyAppName2}"; Check: quicklaunchicon; Components: G3ZBEE;
[Code]
Var
DesktopIconCheckBox: TCheckBox;
StartMenuCheckBox: TCheckBox;
QuickStartCheckBox: TCheckBox;
function desktopicon(): Boolean;
begin
Result := DesktopIconCheckBox.Checked;
end;
function menuicons(): Boolean;
begin
Result := StartMenuCheckBox.Checked;
end;
function quicklaunchicon(): Boolean;
begin
if GetWindowsVersion < $06000000 then begin
Result := QuickStartCheckBox.Checked;
end;
end;
procedure InitializeWizard();
var
ItemsGap: Integer;
begin
ItemsGap := WizardForm.DirBrowseButton.Left - (WizardForm.DirEdit.Left + WizardForm.DirEdit.Width);
DesktopIconCheckBox := TCheckBox.Create(WizardForm.DirEdit.Owner);
DesktopIconCheckBox.Visible := true;
DesktopIconCheckBox.Checked := true;
StartMenuCheckBox := TCheckBox.Create(WizardForm.DirEdit.Owner);
StartMenuCheckBox.Visible := true;
StartMenuCheckBox.Checked := true;
if GetWindowsVersion < $06000000 then begin
QuickStartCheckBox := TCheckBox.Create(WizardForm.DirEdit.Owner);
QuickStartCheckBox.Visible := true;
QuickStartCheckBox.Checked := false;
end;
if true then
begin
DesktopIconCheckBox.Top := WizardForm.DirEdit.Top + WizardForm.DirEdit.Height + ItemsGap / 2;
DesktopIconCheckBox.Width := WizardForm.DirEdit.Width;
DesktopIconCheckBox.Caption := ExpandConstant('{cm:CreateDesktopIcon}');
DesktopIconCheckBox.Parent := WizardForm.DirEdit.Parent;
StartMenuCheckBox.Top := DesktopIconCheckBox.Top + DesktopIconCheckBox.Height + ItemsGap / 2;
StartMenuCheckBox.Width := WizardForm.DirEdit.Width;
StartMenuCheckBox.Caption := ExpandConstant('{cm:MenuStartIcons}');
StartMenuCheckBox.Parent := WizardForm.DirEdit.Parent;
if GetWindowsVersion < $06000000 then begin
QuickStartCheckBox.Top := StartMenuCheckBox.Top + StartMenuCheckBox.Height + ItemsGap / 2;
QuickStartCheckBox.Width := WizardForm.DirEdit.Width;
QuickStartCheckBox.Caption := ExpandConstant('{cm:CreateQuickLaunchIcon}');//SetupMessage(msgNoProgramGroupCheck2);
QuickStartCheckBox.Parent := WizardForm.DirEdit.Parent;
end;
end;
end;

Resources