SDL + MFC
Posted on 2006-06-07
i have an MFC application, which has a main window and in this window i have a button which opens another dialog (lets call it SDL dialog) to display a SDL simulation.
i have created the SDL dialog which the SDL window must run inside ...
it works BUT when i close the SDL dialog and simulate again....after the second or the third time, the whole application quits ith an error message :"....exe has exited with code -1073741819 (0xC0000005)."
i guess its related to how things exit...i mean the momory is not freed correctly....
here is a piece of code:
in the main dialog Simulate button:
SDLDialog = new CDialog;
HWND dlgHandle = SDLDialog->GetSafeHwnd();
simulationScreen = new CSimulationScreen;
simulationScreen->InitializeSDL((int) dlgHandle ); //its initialize and run together
void CSimulationScreen::InitializeSDL(int hWnd)
//now in the simulationscreen class
sprintf(SDL_vidvar, "SDL_WINDOWID=%d", hWnd);
if(SDL_Init( SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE ) < 0)
m_CScreenSurface = SDL_SetVideoMode(m_iScreenWidth, m_iScreenHeight,
COLOR_DEPTH, SDL_HWSURFACE | SDL_DOUBLEBUF);
if(m_CScreenSurface == NULL)
any idea where i can be wrong ...or how to initialize/ quit things correctly...