我在MFC上遇到问题。每当我在无模式对话框上调用DestroyWindow时,我就会在AfxThrowInvalidArgException
中因未处理的异常而崩溃。
检查调用栈,它像1055
中的wincore.cpp
一样崩溃:
ENSURE(pMap != NULL);
在相关的情况下,这就是我创建无模式窗口的方式:
Dialogs::WelcomeDialog = new CRCChatWelcomeDlg( );
m_pMainWnd = Dialogs::WelcomeDialog;
Dialogs::WelcomeDialog->Create( DialogRCChatWelcome, CWnd::GetDesktopWindow( ) );
if ( pShellManager != nullptr )
delete pShellManager;
MSG Message;
while ( GetMessage( &Message, Dialogs::WelcomeDialog->m_hWnd, 0, 0 ) ) {
TranslateMessage( &Message );
DispatchMessage( &Message );
}
Dialogs::MainMenuDialog = new CRCChatMainMenuDlg( );
m_pMainWnd = Dialogs::MainMenuDialog;
Dialogs::MainMenuDialog->Create( DialogRCChatMainMenu );
while ( GetMessage( &Message, Dialogs::MainMenuDialog->m_hWnd, 0, 0 ) ) {
TranslateMessage( &Message );
DispatchMessage( &Message );
}
我这样破坏它:
Dialogs::WelcomeDialog->DestroyWindow( );