Skip to content

Embed leaflet-based maps within classic desktop applications

License

Notifications You must be signed in to change notification settings

ptv-logistics/leaflet-vb6

Repository files navigation

leaflet-vb6

Embed leaflet-based maps within classic desktop applications.

screenshot

Purpose

This sample shows how classic desktop applications can embed modern browser-based controls. The sample routing-machine implements a simple route-planner in VB6. It utilizes this JavaScript sample to be controlled from within the VB6 code.

The Problem

Windows desktop applications can embed modern web widgets with the Windows WebBrowser Control. .NET comes with the System.Windows.Forms.WebBrowser class, which makes it very easy to communicate with the JavaScript page by using InvokeScript() and window.external().

Other IDEs can use the WebBrowser OCX directly, but they need to support IDocHostUIHandler COM interface on the host window to allow two-way communication, which is not easy to implement by your own.

However, you can achieve the same result with some simple tricks:

  • A VB helper method InvokeJs invokes a script on the WebBrowser document and uses the document attribute ExtData to pass input and output parameters.
  • For JavaScript an invokeExternal helper method sets the window.status of the browser to a method name, after setting a document attribute ExtData for the method args.
  • On the VB6 side, the StatusTextChange event can be used as method dispatcher with ExtData for input and output args.

This method doesn't support true object arguments like the .NET control. However with VBJSON object data can be exchanged between VB and JavaScript.

About

Embed leaflet-based maps within classic desktop applications

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published