假设App类为CTestApp 首先在CTestApp类中添加一个成员变量:CGetTimeDlg *dlg;然后在InitInstance()中将原来的: int nResponse = dlg.DoModal(); if (nResponse == IDOK) { // TODO: Place code here to handle when the dialog is // dismissed with OK } else if (nResponse == IDCANCEL) { // TODO: Place code here to handle when the dialog is // dismissed with Cancel } 以及return FALSE;全部删除掉,改为: dlg=new CTestDlg; m_pMainWnd = dlg; return dlg->Create(主窗口ID); 由于没有设置SW_SHOW,故窗体隐藏运行 别忘了在ExitInstance()中加上一句:delete dlg;好了,这下把本程序的对话框变成了一个无模式对话框。不过既然是无模式对话框,就不能再用OnOK(),OnCancel()来退出了,要用DestroyWindow()。
假设App类为CTestApp
首先在CTestApp类中添加一个成员变量:CGetTimeDlg *dlg;然后在InitInstance()中将原来的: int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
}
以及return FALSE;全部删除掉,改为: dlg=new CTestDlg;
m_pMainWnd = dlg;
return dlg->Create(主窗口ID);
由于没有设置SW_SHOW,故窗体隐藏运行
别忘了在ExitInstance()中加上一句:delete dlg;好了,这下把本程序的对话框变成了一个无模式对话框。不过既然是无模式对话框,就不能再用OnOK(),OnCancel()来退出了,要用DestroyWindow()。