m_pMainWnd在MFC中更改为NULL

use*_*369 4 c++ mfc

我在扩展WinApp的类的InitInstance函数中得到了这段代码:

m_pMainWnd = &m_Frame;  // Clearly setting m_pMainWnd to !NULL
m_Frame.LoadFrame(BMP_ICON, 0, NULL, NULL);

m_pMainWnd->GetMenu()->Detach();
m_pMainWnd->SetMenu(NULL);

m_Frame.ShowWindow(SW_SHOW);
m_Frame.UpdateWindow();
Run Code Online (Sandbox Code Playgroud)

然而,当运行时,应用程序打开,显示m_Frame一段时间,然后再次关闭.我得到这个输出:

Warning: calling DestroyWindow in CWnd::~CWnd; OnDestroy or PostNcDestroy in derived class will not be called.
Warning: m_pMainWnd is NULL in CWinApp::Run - quitting application.
The thread 'Win32 Thread' (0x914) has exited with code 0 (0x0).
The program '[6628] VentSizerPro.exe: Native' has exited with code 0 (0x0).
Run Code Online (Sandbox Code Playgroud)

所以沿着m_pMainWnd的某个地方已经改为NULL,但是在哪里以及为什么以及如何以及如何?:(

编辑:

m_Frame是一个类的实例,它使用CFrameWnd来修改窗口框架.

use*_*369 8

不要是白痴..你将指针值赋给了局部变量的值.

  • @TimPost,aaahh !! 当我发表这篇文章时,我没有注意到他自己做错了!:-))) (2认同)