pMainForm = new CMainForm(); //创建主窗口类
if (pMainForm->Create(IDD_DLG_MAIN, NULL) == FALSE)
{
delete pMainForm;
pMainForm = NULL;
return;
}
pMainForm->ShowWindow(SW_SHOW); //显示窗口
在释放的窗口的时候,调用delete MFC类对象,就报异常.
if (pMainForm)
{
//::DestroyWindow(pMainForm->m_hWnd); //MSDN:A thread cannot use DestroyWindow to destroy a window created by a different thread.
//pMainForm->DestroyWindow(); //--调用这个报错,只能在创建窗口的线程中调用
//SendMessage(pMainForm->m_hWnd, WM_DESTROY, NULL, NULL);
//_asm int 3
delete pMainForm; //调用这个会异常
pMainForm = NULL;
}