Is this a memory leak in MFC

后端 未结 3 831
太阳男子
太阳男子 2021-01-02 14:50
// CMyDialog inherits from CDialog 
void CMyFrame::OnBnClickedCreate()
{
    CMyDialog* dlg = new CMyDialog();
    dlg->Create( IDD_MYDIALOG, m_thisFrame );
    d         


        
3条回答
  •  猫巷女王i
    2021-01-02 15:25

    If you manually call Create on a dialog, you have to manually Destroy it as well.
    When using DoModal() this isn't necessary.

    From MSDN:

    Use the CWnd::DestroyWindow function to destroy a dialog box created by the Create function.

提交回复
热议问题