spacer2 1_1 1_2
 The MP2K Update!
Front Cover
What's New
Sample Data
MapPoint 2013
Press Releases
MapPoint Forums
Link to MP2Kmag
Wish List
MapPoint Trial
 Earlier Content
Past News Items
Past What's New Announcements

MapPoint 2013

Programming MapPoint in .NET

MapPoint Book

  Spatial Community
SVG Tutorials

Map Visitors


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 controls window (named ActiveX frame window) of the MapPoint applications 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 messages 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 applications 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 nodes hierarchy. We can make an assumption that the MapPoint applications 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 applications 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 applications main form
 5. Resume processing

Function WaitForDialogWnd below implements the described algorithm. The parameter sWndTitle is the dialogs 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 readers 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)
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.

MP2Kmag Internet

 Recent Discussion
-Agilent.Keysight.Model.Builder MBP v2017
-PaleoScan v2018.1
-Adapt Builder 2018 Win64
-PaleoScan v2017
-Actel Libero SoC Platinum 11.5
-Paladin DesignBased v5.1
-PVsyst v6.77
-Abvent Twinmotion 2019 x64
-PVTSim Nova v3.0
-AWR Microwave Office v14.0.9138.4 Win64
-AWR Design Environment With Analyst v13.0 x64
-AVL workspace v2018
-PTC Arbortext IsoDraw v7.3 M080
-Cost Effective EDB to PST utility from EdbMails
-ATCS Nh*n l*m dịch vụ Kế toán Thuế trọn gói Cho doanh nghiệp mới th*nh l*p
-ATCS Nh*n l*m dịch vụ Kế toán Thuế trọn gói Cho doanh nghiệp mới th*nh l*p
-ATCS Nh*n l*m dịch vụ Kế toán Thuế trọn gói Cho doanh nghiệp mới th*nh l*p
-ATCS Nh*n l*m dịch vụ Kế toán Thuế trọn gói Cho doanh nghiệp mới th*nh l*p
-ATCS Nh*n l*m dịch vụ Kế toán Thuế trọn gói Cho doanh nghiệp mới th*nh l*p
-ATCS Nh*n l*m dịch vụ Kế toán Thuế trọn gói Cho doanh nghiệp mới th*nh l*p
-ATCS Nh*n l*m dịch vụ Kế toán Thuế trọn gói Cho doanh nghiệp mới th*nh l*p
-ATCS Nh*n l*m dịch vụ Kế toán Thuế trọn gói Cho doanh nghiệp mới th*nh l*p
-ATCS Nh*n l*m dịch vụ Kế toán Thuế trọn gói Cho doanh nghiệp mới th*nh l*p
Browse GIS books and periodicals
Find a MapPoint Partner or Consultant
Real Estate Columbia, MO Real Estate

Want Your Site To Appear Here?

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