Similarly: appmsg-warning:destroying non-null m_pMainWnd (This is because you have neither delete nor call DestroyWindow)
First, the first one, the direct column code:
1 classSccapp: PublicCWinApp2 3 classCMainWindow: PublicCFrameWnd4 5 BOOL sccapp::initinstance ()6 {7m_pMainWnd =NewCMainWindow;8 if(!::registerhotkey (M_pmainwnd->getsafehwnd (),0x0001, NULL, vk_f1))9 {Ten:: MessageBox (NULL, _t ("Register F1 Hotkey failed! Please close the hotkey conflicting program and restart the program! "), One_t ("Error"), mb_iconerror); A Delete m_pMainWnd; - returnFALSE; - } theM_pmainwnd->ShowWindow (m_ncmdshow); -M_pmainwnd->UpdateWindow (); - returnTRUE; -}
12 lines, you delete directly, but the window does not receive Wm_destroy and Wm_ncdestroy messages, so it cannot be destroyed correctly, replaced by:
M_pmainwnd->destroywindow ();
you do not need to write the delete manually, because although CWnd's PostNcDestroy will not call delete this, CFrameWnd's PostNcDestroy will call delete this. m_pMainWnd will become null after you call, and you can verify the following code:
if (m_pMainWnd = = null ) std::ofstream OS ("null");
At first I used the delete m_pmainwnd behind M_pmainwnd->destroywindow () to verify that there was no error, because delete null had no effect.
Resolution: Appmsg-warning:calling DestroyWindow in Cwnd::~cwnd; OnDestroy or PostNcDestroy in derived class would not be called