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

  MAPPOINT Q & A  

Top | Post New Question | Read All | MP2K Asks Microsoft

809 vic - July 29, 2002

Trying to use custom pop-up menu on a Mappoint VB application. I got the map object to respond to the mouse down event. Whoever, if you do not resond to the pop-up menu immediately, you get a server error. The same thing happens when you launch a modal form from a map object event. Any feedback would be appreciated. Also, is there in a VB app to have custom menu items be shown in conjunction with the mappoint menu items?

Answers:
July 31, 2002
Vic, Lets see the code you have in the Mouse Down event. John john.meyer@support-pc.com

July 31, 2002
John: Thanks for the follow up. The following is the code in the mouse down event in the map object. It just brings up a popup menu on the right button (2): If Button = 2 Then frmMain.SSActiveToolBars1.PopupMenu "ID_mnuMap" End If The following are my findings: 1. If I put my pop-up menu code in the mouse up event of the map object, it is being ignored and the mappoint menu is poped up. 2. If I put my pop-up menu code in the mouse down event of the map object, then the mappoint popup menu is ignored and my popup menu shows up. Also, if theuser does not respond to this popup menu with few seconds, I get a mappoint generated server error. What I realy want to be able to do is pop up my menu on the mouse up event. Also I would like to know if there is a way to append my menu items to mappoints menu items. Vic

July 31, 2002
Vic, Put your code in the MouseUp event and this code in the MouseDown Event.

If Button = vbRightButton Then

Set wshshell = CreateObject("wscript.shell")

wshshell.SendKeys "{ESC}"
wshshell.SendKeys "{ESC}"
End If

Let me know if this works for you.

John
john@support-pc.com

October 10, 2002
The method given above will effectively cancel the entire click event. After the Esc Esc happens in the BeforeClick event handler, the system does not recognize any further events for this click and so the above method will not work.

Microsoft DOES NOT allow for any modal operations to happen inside mouse click event handlers (see mappoint documentation). The way to get around this is to define a few global variables to save your "click state" (button, x, y) and whether or not a click occurred. In the BeforeClick handler, simply set your globals to be the received button, x, y, and Click_Happened and then set Cancel to true.

Create a timer object on your form that expires every half second or so (you can tweak these values depending on how responsive you need your app vs how much processor time you're willing to use) that checks the Click_Happened variable. If a click happened, then turn off the flag and display your menus. If Click_Happened = False then don't do anything.

This way you can have all of your modal actions outside of MapPoint's event handlers and everybody stays happy.

Post New Answer / Follow-up


Google
 
MP2Kmag Internet


 Recent Discussion
 Resources


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.