c++ - MFC中m_pMainWnd改为NULL

标签 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();

然而,在运行时,应用程序打开,显示 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).

所以 m_pMainWnd 沿线的某处已更改为 NULL,但是在哪里、为什么、如何以及什么? :(

编辑:

m_Frame 是扩展 CFrameWnd 以修改窗口框架的类的实例。

最佳答案

别傻了..你把指针值赋给了局部变量的值。

关于c++ - MFC中m_pMainWnd改为NULL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9975858/

相关文章:

c++ - 进行异步调用后删除 asio 套接字

c++ - 关于一个简单的随机数生成问题的建议。

C++ 创建函数,就像变量一样,稍后更改其主体,然后再调用它

c++ - 在用户键入 MFC 时验证编辑控件的文本

c++ - 如何在 async_read_until 之后使用 asio 缓冲区进行连续读取

c++ - 从进程句柄获取进程信息

c++ - 无法在 MFC 中的 CFile 中设置只读属性?

mfc - 如何通过代码在 mfc 中减少标题栏的窗口?

mfc - VC++ 10 MFC : What is the correct way to do localization

c++ - 我在哪里处理特定 mfc 编辑控件的 "Enter"键事件?