如何消除警告:OnDestroy or PostNcDestroy in derived class will not be called

如何消除警告:OnDestroy or PostNcDestroy in derived class will not be called

转载自: http://blog.csdn.net/aidy22/archive/2009/07/22/4370930.aspx

应用程序中使用指针创建了对话框,在析构函数中使用delete时,会出现以下警告:

Warning: calling DestroyWindow in CDialog::~CDialog --
OnDestroy or PostNcDestroy in derived class will not be called.

我们在释放指针的时候应该先通过对话框指针调用DestroyWindow()方法,然后再用delete删除。

CDlg:: ~ CDlg()
{
 
if (m_pDlg !=  NULL)
 {
  m_pDlg
-> DestroyWindow();
  delete m_pDlg;
 }
}

只有这样才可以把这个警告给去掉


你可能感兴趣的:(如何消除警告:OnDestroy or PostNcDestroy in derived class will not be called)