Search code examples
vb6mappoint

MapPoint not shutting down properly?


I'm trying to use MapPoint's COM API from VB6, running it in application mode, but when I close things down, MapPoint still hangs around! How do I get it to stop cleanly? Yes I've tried calling the Application object's Quit method.


Solution

  • Despite VB6's faults, your life is actually easier with VB6 as most of the samples are written in it. Also there's a garbage collector.

    First make sure all references to MapPoint objects are set to 'nothing' (excluding the Application object). This will let the garbage collector do its job. As well as good memory management, when you come to close MapPoint, the garbage collector will know that all these other objects can be freed. MapPoint will not close until all external references are cleared. Also is the dialog box asking if you want to save appearing? This can be removed by using the Map.Save() method to save the map, or by setting the Map's Saved property to true. This property actually controls the dialog box. You make some changes and it is reset; you save the map, it is set. The dialog box appears if it is set to false.

    Then, finally, call the Application's Quit method, and then for good measure clear the application reference.

    eg.

    myMapPointApp.ActiveMap.Saved = true
    call myMapPointApp.Quit
    set myMapPointApp = Nothing