dll中使用以下代码,报错“内存不能为read”,不知道是不是销毁的方式有问题呢!
void CUpdateDlg::OnClose()
{
// TODO: Add your message handler code here and/or call default
DestroyWindow();
CDialog::OnClose();
}
void CUpdateDlg::OnClose()
{
// TODO: Add your message handler code here and/or call default
DestroyWindow();
CDialog::OnClose();
}
再DestroyWindow();
再DestroyWindow();还是不行DestroyWindow(); 会被主动调用?应该没有的,关闭对话框后,重新打开,看到对话框中的进度条还在继续走
{
delete this;
}
重载OnNcDestroy,并注释掉原来的调用。
void CUpdateDlg::OnClose()
{
// TODO: Add your message handler code here and/or call default
DestroyWindow();
//CDialog::OnClose();
} CDialog::OnClose(); 注释掉。
重载OnNcDestroy和CDialog::OnClose(); 注释掉。 都不行
我的对话框是CUpdateDlg *uDlg;uDlg = new CUpdateDlg();出来的
就是这个出的错,去掉这个就没问题,但是对话框不能真正的销毁
响应WM_CLOSE消息,执行DestroyWindow;重载PostNcDestroy函数,delete this;如果需要退出消息循环,则响应WM_DESTROY消息,PostQuitMessage。
{
switch(message)
{
....
case WM_DESTROY:
PostQuitMessage(0);
break;
}}
void CUpdateDlg::PostNcDestroy()
{
// TODO: Add your specialized code here and/or call the base class
CDialog::PostNcDestroy();
delete this;
}
void CUpdateDlg::OnClose()
{
// TODO: Add your message handler code here and/or call default
CDialog::OnClose();
DestroyWindow();
}
如果想把new出来的dlg类对象在窗口关闭后自动释放掉,则再重载PostNcDestroy函数,调用delete this,也可以不重载这个函数,手动来控制dlg类对象
要是不加PostQuitMessage的话,可以关闭,但是重新打开对话框就会出错的,