spacer1
spacer2 1_1 1_2
2_1
 Subscribe
 The MP2K Update!
 
 
 
 Magazine
Front Cover
What's New
Articles
News
Sample Data
Gallery
Advertise
About
 Features
MapPoint 2013
Press Releases
MapPoint Forums
Companies
Link to MP2Kmag
Wish List
MapPoint Trial
Authors
 Earlier Content
Past News Items
Past What's New Announcements
 Sponsors
 Order

MapPoint 2013

Programming MapPoint in .NET

MapPoint Book

  Spatial Community
SVG Tutorials
MapPoint

Map Visitors

  ARTICLES  


Extending the MapPoint ActiveX Control - Pt. II

Sergiy Pavlov continues his exploration on how to unleash the full functionality of MapPoint in the ActiveX control

Part Two of Two

1. Introduction to Part II

In Part I of this article we made the LocationSensor command functionality programmatically accessible for MapPoint 2002 ActiveX control users. We introduced clsMapPoint class and hWnd_Frame property to dynamically locate a window handle of the internal ActiveX control’s window (named ‘ActiveX frame window’) of the MapPoint application’s main frame window. We could then mimic the LocationSensor user interface (menu) event by posting WM_COMMAND message # 35331 to a window captured by hWnd_Frame. The same technique could be similarily used with a number of other MapPoint menu commands. The only implementation difference between them would be WM_COMMAND message’s value, for example:

 Menu Tools -> MeasureDistance: # 58224
 Menu File -> SaveAs: # 57604
 Menu File -> ExportToPocketStreets: # 35334
 Menu File -> Print: # 55955

However, Menu File -> SaveAsWebPage (#35032) command message had no effect whatsoever. Frankly, I sorted out all the internal ActiveX control windows as possible command message targets and was already thinking giving up, when something unexpected in the Microsoft Spy++ Windows View caught my eye.

2. An alternative MapPoint window

Download and expand Test VB project - Part2. If you have the European version of MapPoint, set conditional compilation argument EURO to 1 in Project properties ->make

Run the Microsoft Spy++ utility together with the Test VB application (note, that this time we run the test alone, without the MapPoint application). In the Spy++ Windows View you can now find a top-level node corresponding to ‘MapPoint’ application (Fig.2 in Part I of this article) as well as a stand-alone node “Map - Microsoft MapPoint North America” (Fig.6) reminding us the MapPoint application’s main frame window (Fig.1 in Part I of this article):


Figure 6

There is a difference in how complex the structure of the window objects contained by the top-level “Map- Microsoft MapPoint North America” window: this time there is only one child object under the node’s hierarchy. We can make an assumption that the MapPoint application’s main frame window does always exist, even if invisible and empty, - no matter how you are running MapPoint: the application itself or the control-based custom aplication. So the next step will be testing that hidden window on response to SaveAsWebPage (#35032) command message. To find the MapPoint main frame window dynamically use hWnd_EXE property of the extension class:

To activate SaveAsWebPage programmatically, we will post WM_COMMAND message # 35032 to a window captured by hWnd_EXE property:

The test VB application executes that code by choosing File -> TEST SaveAsWebPage... Test application menu command. Doing that makes the ‘Save as web page’ dialog appear. Check whether it functions correctly. It does, except that the dialog is not modal as it should be (you can click on the main application window).

3. Simulate modal window using Win API

To simulate the ‘modal’ behaviour, follow these steps after activating ‘Save as web page’ dialog:
 1. Disable the application’s main form
 2. Make the dialog window topmost (use WinAPI)
 3. Wait until the dialog window is closed by user (use WinAPI to detect it)
 4. Enable the application’s main form
 5. Resume processing

Function WaitForDialogWnd below implements the described algorithm. The parameter sWndTitle is the dialog’s window title, so we may reuse the code to emulate modal behaviour for different dialog windows, if needed:

Test now the ‘Save as web page’ dialog behaviour by choosing File -> Save As Web Page... Test application menu command.

4. Putting it all together

Now, as we have number of MapPoint menu commands implemented through different API calls, it makes sense to group them by the parent menu (File, Edit, etc.) and create a common method SendCommand with a Select Case statement in it to dispatch a command to the specific routine. That simplifies the class clsMapPoint interface and makes its use straightforward, like in the example below:

I leave it to the reader’s consideration which functionality does indeed require the WinAPI –based technique, or can be better implemented using existing ActiveX interface. In the test application I tried to implement the complete set of MapPoint menu commands (at least as complete as I could) using only the technique of interest. I would, however, like to point out that the proposed algorithm and the implementation code might require further fine-tuning as well as de-bugging. Also, it could become fully or partially obsolete (simply stop working) in the future versions of the MapPoint software.

Discuss this story in the forum.

Author: Sergiy Pavlov
Email: baal_2000(AT)yahoo.com
Sergiy Pavlov is a GIS/GPS/Tracking Solutions Developer for GEOTAB North America in Burlington, ON. Professional interests range from software and algorithms development to electrical engineering.



Google
 
MP2Kmag Internet


 Recent Discussion
-GCPowerStation v17.2
-GCPowerStation v17.2
-Gaussian 09W v8.0 Rev B.01 SMP
-Gaussian 09 E.01 Linux64
-Atmel Studio v.7.0.1931
-Steinberg Cubase Elements v9.5.40 WiN
-Nero Platinum 2019 Suite 20.0.05900 Multilingual
-Serif DrawPlus X8 14.0.0.19
-PROMT Master 19 Final + PROMT 19 Dictionary Collection
-Apple Logic Pro X v.10.4.2 Multilanguage (MacOSX)
-PROMT Expert 19 Final + PROMT 19 Dictionary Collection
-Waves Complete v2018.10.16 WiN by R2R
-VMware Fusion Pro 10.1.1 MacOSX
-Foxit Phantompdf Business v.9.3.0.10826 Multilanguage
-Bluestacks v4.31.56.2510 Multilingual
-Xara Web Designer Premium 16.0.0.55162 (x64) Portable
-Adobe Bridge CC 6.1.1.10 Update 3 by m0nkrus
-Garmin MapSource v5.4
-Alien Skin Exposure X4 Bundle 4.0.2.43 | macOS
-Unity Asset Cubebrush - Scrap City Assets 1.0 x64
-Magix Samplitude Pro X3 Suite v.14.4.0.518 Multilanguage
-Waves Complete v2018.10.16
-Oxygen XML Editor 18.0 (Win/Mac/Lnx)
-Steinberg Cubase Elements v9.5.40 WiN
-The Foundry Nuke Studio 11.2v4 Win x64
 Resources
Browse GIS books and periodicals
Find a MapPoint Partner or Consultant
Real Estate Columbia For Sale By Owner


Want Your Site To Appear Here?

   © 1999-2012 MP2K. Questions and comments to: website@mp2kmag.com
  Microsoft and MapPoint 2002/2004/2006/2009/2010/2011/2013 are either trademarks or registered trademarks of Microsoft.