Inno Setup - Change the MessageBox language - programming-languages

i have this problem... i did a personal messagebox... i put in a very funny way english and spanish... but i want my installer to display only one language... like... when i choose in the menu selector spanish... in that messagebox shows spanish... if a choose italian in the menu selector... let that messagebox show itallian.
[code]
function NextButtonClick1(PageId: Integer): Boolean;
begin
Result := True;
if (PageId = wpSelectDir) and not FileExists(ExpandConstant('{app}\xxx.exe')) then begin
MsgBox('"Thi App" does not seem to be installed in that folder. Please select the correct folder. [Selecciona la Carpeta de Instalación de la Aplicación]', mbError, MB_OK);
Result := False;
exit;
end;
end;

Use the [CustomMessages] section and prefix the message names there with the internal name of the language like shown in the following script:
[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program
OutputDir=userdocs:Inno Setup Examples Output
[Languages]
Name: en; MessagesFile: "compiler:Default.isl"
Name: es; MessagesFile: "compiler:Languages\Spanish.isl"
[CustomMessages]
en.AppCheckError=Select the application folder!
es.AppCheckError=Selecciona la Carpeta de Instalación de la Aplicación!
[Code]
procedure InitializeWizard;
begin
MsgBox(ExpandConstant('{cm:AppCheckError}'), mbInformation, MB_OK);
end;

Related

Inno Setup insert a logo/image in between text

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.

Inno Setup Custom Page with Google Map

I'm currently using Inno Setup to create an installer, this requires a google map. for the Map I am using TLama's inno-web-browser.
So I have a custom InputQueryPage displaying a google map. along with 2 input boxes for latitude and longitude when the user clicks on the map it shows the coordinates in an info window.
Is it possible to parse the coordinates so that the 2 input boxes above can be populated from the the map with the lat and long ?
the above can then hopefully be written to the registry as a in float format.
but that is another question..
thanks for any replies regarding this..
What you're asking would require specific JavaScript interop which is not easy to implement. Hence I would suggest you making those edit boxes in JavaScript from where you will interop with the Google Maps API and read the values once you leave the page with the browser. I've added the access to the OleObject through the new WebBrowserGetOleObject function to the plugin.
Here is an example JavaScript with 2 input boxes (that you will synchronize from Google Maps API in your script). This script is in the following example referred by the fixed file name (in real change that to a temporary file extracted from the setup package):
<!DOCTYPE html>
<html>
<body>
<input id="latinput" type="text">
<input id="loninput" type="text">
</body>
</html>
In Inno Setup you can then read values from those input boxes this way:
[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program
[Files]
Source:"WebBrowser.dll"; Flags: dontcopy
[Code]
const
EVENT_BEFORE_NAVIGATE = 1;
EVENT_FRAME_COMPLETE = 2;
EVENT_DOCUMENT_COMPLETE = 3;
type
TWebBrowserEventProc = procedure(EventCode: Integer; URL: WideString);
procedure WebBrowserCreate(ParentWnd: HWND; Left, Top, Width, Height: Integer;
CallbackProc: TWebBrowserEventProc);
external 'WebBrowserCreate#files:webbrowser.dll stdcall';
procedure WebBrowserDestroy;
external 'WebBrowserDestroy#files:webbrowser.dll stdcall';
procedure WebBrowserShow(Visible: Boolean);
external 'WebBrowserShow#files:webbrowser.dll stdcall';
procedure WebBrowserNavigate(URL: WideString);
external 'WebBrowserNavigate#files:webbrowser.dll stdcall';
function WebBrowserGetOleObject: Variant;
external 'WebBrowserGetOleObject#files:webbrowser.dll stdcall';
var
CustomPage: TWizardPage;
procedure InitializeWizard;
begin
CustomPage := CreateCustomPage(wpWelcome, 'Web Browser Page',
'This page contains web browser');
WebBrowserCreate(WizardForm.InnerPage.Handle, 0, WizardForm.Bevel1.Top,
WizardForm.InnerPage.ClientWidth, WizardForm.InnerPage.ClientHeight - WizardForm.Bevel1.Top, nil);
WebBrowserNavigate('C:\AboveScript.html');
end;
procedure DeinitializeSetup;
begin
WebBrowserDestroy;
end;
procedure CurPageChanged(CurPageID: Integer);
begin
WebBrowserShow(CurPageID = CustomPage.ID);
end;
function NextButtonClick(CurPageID: Integer): Boolean;
var
Latitude: Variant;
Longitude: Variant;
OleObject: Variant;
begin
Result := True;
if CurPageID = CustomPage.ID then
begin
OleObject := WebBrowserGetOleObject;
if not VarIsNull(OleObject) then
begin
Latitude := OleObject.Document.GetElementByID('latinput').value;
Longitude := OleObject.Document.GetElementByID('loninput').value;
MsgBox(Format('Lat: %s, Lon: %s', [Latitude, Longitude]), mbInformation, MB_OK);
end;
end;
end;

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;

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.

How can I add a check box for optional files during install in Inno Setup?

I'm trying to make a custom checkbox in my custom page (because it's a one page installer), is needed only a checkbox without dialogs or anything, the installer that I'm trying to compile is very linear and simple.
I want to bind FILE3.EXE on a checkbox in this way: if checkbox is checked copy the file (FILE3.EXE) in DestDir, otherwise if checkbox is unchecked skip the file (FILE3.EXE) during installation.
This is the code that I used, obviously the checkbox code is missing because I'm not able to do that
[Files]
Source: FILE1.EXE; DestDir: {app};
Source: FILE2.EXE; DestDir: {app};
Source: FILE3.EXE; DestDir: {app}; //OPTIONAL
[Code]
procedure ExitProcess(uExitCode: UINT);
external 'ExitProcess#kernel32.dll stdcall';
var
MainPage : TWizardPage;
FolderToInstall : TEdit;
InstallLocation : String;
procedure CancelClick(Sender: TObject);
begin
if ExitSetupMsgBox then
begin
ExitProcess(0);
end;
end;
procedure BrowseClick(Sender : TObject);
var
Dir : String;
begin
Dir := FolderToInstall.Text;
if BrowseForFolder('Browse',Dir,false) then
FolderToInstall.Text := Dir;
WizardForm.DirEdit.Text := Dir;
end;
procedure InitializeWizard();
var
LabelFolder : TLabel;
begin
MainPage := CreateCustomPage(wpWelcome,'','');
LabelFolder := TLabel.Create(MainPage);
LabelFolder.Parent := WizardForm;
LabelFolder.Top := 164;
LabelFolder.Left := 6;
LabelFolder.Caption := 'Directory:'
FolderToInstall := TEdit.Create(MainPage);
FolderToInstall.Parent := WizardForm;
FolderToInstall.Top := 182;
FolderToInstall.Left := 85;
FolderToInstall.Width := 380;
FolderToInstall.Text := WizardDirValue;
FolderToInstall.ReadOnly := True;
end;
You don't have to manually create checkboxes for that. The standard way to let the user choose what to install is to use the [Types] and [Components] sections of your script file.
Take a look at the Components.iss script located in your Inno Setup install folder\examples.
; -- Components.iss --
; Demonstrates a components-based installation.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING .ISS SCRIPT FILES!
[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
[Files]
Source: "MyProg.exe"; DestDir: "{app}"; Components: program
Source: "MyProg.chm"; DestDir: "{app}"; Components: help
Source: "Readme.txt"; DestDir: "{app}"; Components: readme\en; Flags: isreadme
Source: "Readme-German.txt"; DestName: "Liesmich.txt"; DestDir: "{app}"; Components: readme\de; Flags: isreadme
[Icons]
Name: "{group}\My Program"; Filename: "{app}\MyProg.exe"
At runtime, the installer presents this dialog within the wizard:
You need to make a Check function which will return state of the check box from the [Code] section of your script. Something like this might do what you want, but before the code script I would correct you in the following:
use TNew... classes where you're able to, so in your case use TNewEdit instead of TEdit
use TWizardPage.Surface as a Parent if you want to have a certain component on the page (here I'm not sure if that's your intention, just pointing this out :-)
format your code, it doesn't need to be so flat
In the following example I've used Check function called InstallHelpFile for conditional install of a certain file, in this case MyProg.chm. The Check function works simply; when you return True to the function, the file is processed, skipped is when you return False.
[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program
OutputDir=userdocs:Inno Setup Examples Output
[Files]
Source: "MyProg.exe"; DestDir: "{app}"
Source: "MyProg.chm"; DestDir: "{app}"; Check: InstallHelpFile;
[Code]
var
InstallHelpCheckBox: TNewCheckBox;
procedure InitializeWizard;
var
LabelFolder: TLabel;
MainPage: TWizardPage;
FolderToInstall: TNewEdit;
begin
MainPage := CreateCustomPage(wpWelcome, '', '');
LabelFolder := TLabel.Create(MainPage);
LabelFolder.Parent := WizardForm;
LabelFolder.Top := 164;
LabelFolder.Left := 6;
LabelFolder.Caption := 'Directory:'
FolderToInstall := TNewEdit.Create(MainPage);
FolderToInstall.Parent := MainPage.Surface;
FolderToInstall.Top := 182;
FolderToInstall.Left := 85;
FolderToInstall.Width := 380;
FolderToInstall.Text := WizardDirValue;
FolderToInstall.ReadOnly := True;
InstallHelpCheckBox := TNewCheckBox.Create(MainPage);
InstallHelpCheckBox.Parent := MainPage.Surface;
InstallHelpCheckBox.Top := FolderToInstall.Top + FolderToInstall.Height + 8;
InstallHelpCheckBox.Left := FolderToInstall.Left;
InstallHelpCheckBox.Width := FolderToInstall.Width;
InstallHelpCheckBox.Caption := 'Install help file';
end;
function InstallHelpFile: Boolean;
begin
{ here is the Check function used above; if you return True to this }
{ function, the file will be installed, when False, the file won't }
{ be installed }
Result := InstallHelpCheckBox.Checked;
end;
You can do it much easier with CreateInputOptionPage(). See detailed information in Inno Setup help. http://www.jrsoftware.org/ishelp/index.php?topic=scriptpages
// Create:
for i := 0 to g_SetupX_Count do begin
WizardForm.ComponentsList.AddCheckBox(g_SetupX_Name[i], '', 0, g_SetupX_Active[i], true, false, false, nil);
g_SetupX_CompListIndex[i] := nextPosi;
nextPosi := nextPosi + 1;
end;
// Evaluate:
for i := 0 to g_SetupX_Count do begin
g_SetupX_Active[i] := WizardForm.ComponentsList.Checked[g_SetupX_CompListIndex[i]];
end;

Resources