DoubleLi

qq: 517712484 wx: ldbgliet

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
非模态对话框需要重载OnCanel方法, 并调用DestroyWindow, 且不能调用基类的OnCanel
重载PostNcDestroy, 需要delete掉this指针

// Overrides
    // ClassWizard generated virtual function overrides
    //{{AFX_VIRTUAL(CDlgTest)
    protected:
    virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
    virtual void PostNcDestroy();
    //}}AFX_VIRTUAL

// Implementation
protected:

    // Generated message map functions
    //{{AFX_MSG(CDlgTest)
    virtual void OnOK();
    virtual void OnCancel();
    //}}AFX_MSG


void CDlgTest::OnOK() 
{
    // TODO: Add extra validation here
}

void CDlgTest::OnCancel() 
{
    DestroyWindow();
}

void CDlgTest::PostNcDestroy() 
{
    // TODO: Add your specialized code here and/or call the base class
    
    CDialog::PostNcDestroy();
    delete this;
}

posted on 2013-10-30 16:26  DoubleLi  阅读(496)  评论(0)    收藏  举报