Access Violation

dcarl
02-11-2003, 12:59 PM
I have a vc++ dialog app with dialogs in a tab control. One of the dialogs has the mappoint control in it. When I try to call m_mappointcontrol->NewMap(northamerica) I get an access violation. I can only call the NewMap from a button on the actual dialog with the mappoint control.

Have you seen this behavior? Has anyone found a solution?

thanks in advance

discostu
05-25-2005, 04:04 PM
I, too, get an access violation after I create a NewMap in my application. I made it so that when my app starts up, the MappointCtrl is hidden and there is a CListCtrl shown in the same place. I have a button that shows the MappointCtrl and hides the CListCtrl. The map shows up fine. And the first time I run the application after doing a "Rebuild All" it runs fine. But every time I run it after that I get an Access Violation and it shows me the dissassembly (which doesn't really help me figure out what's going on).

void CMainFrame::OnMapView( ) {
CRouteProgressView* pRPV = NULL;
CRoadRunnerMobileApp* pApp = (CRoadRunnerMobileApp*)AfxGetApp();

if (pApp != NULL)
pRPV = pApp->pProgressView; // pointer to the dialog class with the controls
else
return;

CListCtrl *list = pRPV->getListCtrl();
CMappointCtrl *map = pRPV->getMapCtrl();

if( !map->IsWindowVisible() ) {
list->ShowWindow( SW_HIDE );
map->ShowWindow( SW_SHOW );
map->SetActiveWindow();
pRPV->createNewMap();
} else {
map->CloseMap();
list->ShowWindow( SW_SHOW );
map->ShowWindow( SW_HIDE );
}

}

--------------------------------
class CRouteProgressView : public CFormView
{
...
CMappointCtrl* getMapCtrl() { return &m_Map; };
CListCtrl* getListCtrl() { return &m_List; };
void createNewMap() {
VARIANT a;
a.vt = VT_I4;
a.lVal = 1; // 1 for America 2 for geoMapEurope!
m_Map.NewMap(a);
};
...}


Any ideas? Thanks!

dcarl
05-25-2005, 04:38 PM
The interface changes in the .net ide aka (vc++7.0) and fixes this.

Wilfried
05-26-2005, 04:51 AM
Hi,

I have a vc++ dialog app with dialogs in a tab control. One of the dialogs has the mappoint control in it. When I try to call m_mappointcontrol->NewMap(northamerica) I get an access violation. I can only call the NewMap from a button on the actual dialog with the mappoint control.

You mean the dialog is created but not visible ? Yes, if that's the case you must show it (modal or not), then load the map and eventually hide it if you want. If you dont want to have the map visible for a moment you can make it zero pixels height/width, or put another control above it.

Wilfried
05-26-2005, 05:29 AM
Hi,

the first time I run the application after doing a "Rebuild All" it runs fine. But every time I run it after that I get an Access Violation

There is no difference between the first run after a rebuild and supsequent runt, however it is possible that you still have a mappoint instance running in memory for a while, if your application does not do a nice cleanup for some reason.

Eventually check with task manager, or make a small application that remove all mappoint instances out of memory before a second run to see if that is the reason.

To remove all mappoint instances there is example of it in FAQ.

 
Web mp2kmag.com
mapforums.com