Custom context menu

Anonymous
09-10-2004, 05:22 PM
I'm asking here after searching this forum and googling for hours - I thought I'd find an answer but no joy so far.

Using the ActiveX control and .NET. All I'd like to do is create my own context menu when the user right-clicks a pushpin. I can trap when the right mouse button is clicked, but I can't seem to figure out how to get the pushpin object (or even just the Name property) from the user's click.

You can get the x,y coordinates of the click event, but how do I find a pushpin from that?

Thanks,
Mike

Anonymous
09-10-2004, 05:43 PM
Funny how you can search differently after you post a question. This seems to get the name ok, which I can work with, would still be open to suggestions.

private void axMap_SelectionChange(object sender, AxMapPoint._IMappointCtrlEvents_SelectionChangeEve nt e)
{
MapPoint.Pushpin pushPin = (MapPoint.Pushpin)e.pNewSelection;
MessageBox.Show(pushPin.Name);
}


Mike

Anonymous
09-10-2004, 08:52 PM
I'm also interested in a custom properties menu -- anybody have any idea on this?

Anonymous
09-10-2004, 10:15 PM
FWIW, this is what I'm doing so far, but really, I'm not sure of the best way. I just need to put together some demo/proof of concept real quick.

private void axMap_SelectionChange(object sender, AxMapPoint._IMappointCtrlEvents_SelectionChangeEve nt e)
{
MapPoint.Pushpin pushPin = (MapPoint.Pushpin)e.pNewSelection;
if (pushPin == null)
{
// I guess other objects besides pushpins can get selected.
//MessageBox.Show("pushPin is null");
}
else
{
ContextMenu cm = new ContextMenu();
cm.MenuItems.Add("Do something with " + pushPin.Name); // To do: Wire the event handlers.
cm.Show(axMap, new Point(42, 42)); // Figure out how to position.
//MessageBox.Show(pushPin.Name);
}
}


I hope something like that will work. Not sure about the so-called "Dreaded Server is Busy" business, looks like I need to set a timer to dispose of the context menu. Heck if I know :)

Mike

 
Web mp2kmag.com
mapforums.com