Dialog在Windows Mobile上不能关闭
我创建了一个非常简单的MFC应用程序,当我单击一个按钮时调用一个对话框,并在5秒后发送一个MessageBox。
问题是,当我在第二个对话框中时,我从父窗口中消除了MessageBox(不是单击MessageBox的OK按钮,我单击第二个对话框的空白部分)当我无法关闭对话框时(第二个对话框)单击确定或取消按钮。
为什么?
部分代码:
Main Dlg:
BOOL Cmult_rc_testDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
SetTimer(1, 5000, NULL);
return TRUE; // return TRUE unless you set the focus to a control
}
void Cmult_rc_testDlg::OnBnClickedButton1()
{
CDlg1 a;
a.DoModal();
}
void Cmult_rc_testDlg::OnTimer(UINT_PTR nIDEvent)
{
KillTimer(nIDEvent);
MessageBox(L"oi");
CDialog::OnTimer(nIDEvent);
}
第二个对话框是由MFC向导生成的默认代码。
不知道我完全理解你的问题。 。 。 这听起来像你正试图关闭父窗口时仍显示消息框?
如果是这样的话,父窗口拥有消息框,并且在消息框关闭之前不允许获取焦点。 你可以尝试使用
::MessageBox(NULL, L"oi", L"MessageBox", MB_OK);
而不是MessageBox,它将创建一个消息框,允许您将焦点还原到原始窗口(The ::意味着使用MessageBox的全局命名空间版本,这是Windows本机调用而不是MFC)。
链接地址: http://www.djcxy.com/p/39231.html上一篇: Dialog not close on Windows Mobile
下一篇: ASP.NET MVC 5 generates right url but executes wrong Action
