MFC DestroyWindow导致崩溃

时间:2018-11-26 18:28:45

标签: c++ mfc crash

我在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( );

0 个答案:

没有答案