Possible Duplicate:
Should “delete this” be called from within a member method?
Is is correct to call delete from OnOk event handler function, as in the code below.
void CTestDlg::OnOK()
{
CDialog::OnOK();
this->DestroyWindow();
delete this;
}