使用Google Map的Inno Setup自定义页面 [英] Inno Setup Custom Page with Google Map

查看:56
本文介绍了使用Google Map的Inno Setup自定义页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我当前正在使用Inno Setup创建安装程序,这需要一张Google地图.对于地图,我正在使用TLama的inno-web-browser.

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.

所以我有一个自定义的InputQueryPage,它显示一个Google地图.当用户单击地图时,还有2个用于输入经度和纬度的框,它在信息窗口中显示坐标. 是否可以解析坐标,以便上面的2个输入框可以由地图上的经纬度和经度填充? 然后可以将上述内容以浮点格式写入注册表. 但这是另一个问题.

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..

感谢对此的任何答复.

推荐答案

您要问的是需要特定的JavaScript互操作,而互操作并不容易实现.因此,我建议您在JavaScript中创建这些编辑框,并在其中与Google Maps API互操作,并在离开浏览器页面后读取这些值.我已经添加了对 OleObject 的访问权限通过新的WebBrowserGetOleObject函数添加到插件.

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.

这是一个示例JavaScript,带有2个输入框(您将从脚本中的Google Maps API进行同步).在以下示例中,此脚本以固定文件名(实际上是从安装程序包中提取的临时文件的名称)引用的:

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>

然后在Inno Setup中,您可以通过以下方式从这些输入框中读取值:

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;

这篇关于使用Google Map的Inno Setup自定义页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆