非模态对话框的消除问题
我在视图中通过调用OCREATE产生非模态对话框。消除对话框后,再次想产生这个对话框,程序就错误了,不知道什么问题啊?
代码如下:
CColorDlg *p_ColorDlg = new CColorDlg;//定义为全局变量
void CPhototryView::OnMenuColor()
{
// TODO: Add your command handler code here
p_ColorDlg->Create(IDD_COLOR,this);
p_ColorDlg->ShowWindow(SW_SHOW);
}
void CColorDlg::OnClose()
{
// TODO: Add your message handler code here and/or call default
CDialog::OnClose();
DestroyWindow ();
delete this;
p_ColorDlg = NULL;
}