我正在开发一个 MFC 应用程序并将其导出到 dll 中。该应用程序只有一个窗口,我希望该窗口无模式。在 InitInstance() 内部,如果我希望它是模态的,我只需要这样做:
AFX_MANAGE_STATE(AfxGetStaticModuleState());
CUIWelcomeDlg dlg;
m_pMainWnd = &dlg;
INT_PTR 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;
它作为一个模态工作得很好。这是无模式的代码:
AFX_MANAGE_STATE(AfxGetStaticModuleState());
CUIWelcomeDlg * dlg;
dlg=new CUIWelcomeDlg();
m_pMainWnd=dlg;
if(dlg!=NULL) {
dlg->Create(IDD_UIWELCOME_DIALOG,NULL);
dlg->ShowWindow(SW_SHOW);
}
return true;
我试图调试它。在它达到 return true 之前很好;之后,对话窗口冻结并且没有响应。有谁知道如何解决这一问题?