Solution: Appmsg-warning:calling DestroyWindow in Cwnd::~cwnd; OnDestroy or PostNcDestroy in derived class would not be called

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.