16,473
社区成员
发帖
与我相关
我的任务
分享
virtual void OnOK();
virtual void OnCancel();
void CNewDlg::OnOK()
{
// TODO: Add your control notification handler code here
DestroyWindow();
// OnOK();
}
void CNewDlg::OnCancel()
{
// TODO: Add your control notification handler code here
DestroyWindow();
// OnCancel();
}
void CMainFrame::OnMyDlg()
{
// TODO: Add your command handler code here
if(!FindWindow(NULL, TEXT("信息显示"))) //如果对话框还没有被实例化过
{
m_LevelDlg.Create(MAKEINTRESOURCE(IDD_MYDLG));
m_LevelDlg.ShowWindow(SW_SHOW);
}
}
[/quote]
试了一下,确实如此,解决办法就是重写对话框的OnOK和OnCancel,用上DestroyWindow
void CNewDlg::OnBnClickedOk()
{
// TODO: Add your control notification handler code here
DestroyWindow();
// OnOK();
}
void CNewDlg::OnBnClickedCancel()
{
// TODO: Add your control notification handler code here
DestroyWindow();
// OnCancel();
}
void CMainFrame::OnMyDlg()
{
// TODO: Add your command handler code here
if(!FindWindow(NULL, TEXT("信息显示"))) //如果对话框还没有被实例化过
{
m_LevelDlg.Create(MAKEINTRESOURCE(IDD_MYDLG));
m_LevelDlg.ShowWindow(SW_SHOW);
}
}