PDA

View Full Version : MapPoint Control vs MapPoint with Add-in



profmuggs
08-03-2012, 07:52 AM
We have an application that currently uses a MapPoint control for routing and I have recently been writing an Add-in for MapPoint that uses a windows form as a floating toolbar with the added functions of the Add-in. Now when I open the application with the MapPoint control, the toolbar pops up. I have tried a bunch of different tests like:

if ((thisApp.Parent.Name.ToString().Equals("Microsoft MapPoint")) && (thisApp.Toolbars[3].Visible))

if (thisApp.Parent is MapPoint.Application)
but I can't seem to get the Add-in to recognize if it is running in MapPoint or in a MapPoint control. Has anyone had any luck with this?

My second question: Since the Add-in works in the MapPoint control, I would like to grab the route mileage before the control is closed. So far I can an accurate mileage with
thisApp.ActiveMap.ActiveRoute.Distance from the OnDisconnection or OnBeginShutdown events when I have an active route in MapPoint itself, but it doesn't seem to work from the MapPoint control. The control always gets a result of 0. Has anyone had any luck with this?

Thanks

profmuggs
08-08-2012, 10:19 AM
I decided to make the floating toolbar only accessible by opening it in the MapPoint tools menu. This solves the problem of the toolbar popping up when the MapPoint control is opened.

I am still having trouble getting the current route's distance to show anything other than 0 in the OnDisconnection and OnBeginShutdown events. Does anyone know if these are supposed to work in the MapPoint Control?

Mattys Consulting
08-09-2012, 12:26 PM
I use the ActiveRoute with several applications from the MapPoint ActiveX control.
The entire object model is available.
Sounds like everything is set to Nothing before OnDisconnection and OnBeginShutdown.

profmuggs
08-09-2012, 04:09 PM
Thanks but that wasn't the problem. It seems like the OnDisconnection and OnBeginShutdown events actually run after the map is closed when the events fire from within a control. If I get the value of thisApp.ActiveMap.ActiveRoute.Distance using a button before the window closes, I can get the distance of the current route. If I use the same code within the disconnection events, I get nothing but 0's for the distance.