in MainDlg function
LRESULT CMainDlg::OnDo(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) { CMyDlg* dlg = new CMyDlg;
in CMyDlg
class CMyDlg : public CDialogImpl<CMyDlg>, public CUpdateUI<CMyDlg>, public CMessageFilter, public CIdleHandler, public CWinDataExchange<CMyDlg>, public CDialogResize<CMyDlg> LRESULT CMyDlg::OnCancel(WORD , WORD wID, HWND , BOOL& ) { DestroyWindow(); }
therefore the pointer CMyDlg * dlg will be lost ... (memory leak)
i google for dialogue of models. Mark this post at msdn.com
http://msdn.microsoft.com/en-us/library/zhk0y9cw(VS.80).aspx
note: This example uses a very simple mechanism: it deletes this in PostNcDestroy - a function that is called after the non-client area of ââa field has been destroyed.
but it is in MFC. I use it for WTL. when remove it; he will be approved on
virtual ~CWindowImplRoot() { #ifdef _DEBUG if(m_hWnd != NULL)
SO:
What is the correct way to remove a pointer to a modeless dialog?
Thank you for your help!
MADE:
http://tech.groups.yahoo.com/group/wtl/message/4444
OnFinalMessage is equivalent to the WTL MFC PostNCDestroy, and you can safely let your suicide window frame there :)
void CSetRecordInfoDlg::OnFinalMessage( HWND ) { delete this; }
which is working!