Inno Setup Custom Page with Google Map - inno-setup

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;

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 - How to loop video playback with Inno Media Library

How to define that the medial playback callback function restarts a video playback?
I use a code from this question:
Inno Setup - video file with relative path as splash screen
procedure OnMediaPlayerEvent(EventCode, Param1, Param2: Integer);
begin
if EventCode = EC_COMPLETE then
VideoForm.Close; { not close, start again, and again.... }
end;
PD: Sorry for my bad english.
Maybe there's a more elegant solution, but a trivial one is to simply reinitialize the video playback:
procedure OnMediaPlayerEvent(EventCode, Param1, Param2: Integer);
var
Width: Integer;
Height: Integer;
begin
if EventCode = EC_COMPLETE then
begin
DSInitializeVideoFile(
'd:\Video.avi', VideoForm.Handle, Width, Height, #OnMediaPlayerEvent);
DSPlayMediaFile;
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.

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