Dialog not close on Windows Mobile
I made a very simple MFC application that call a Dialog when I click in a button, and send a MessageBox after 5 seconds.
The problem is, when I was in the second dialog and I dismiss the MessageBox from the parent (not click OK button of MessageBox. I click in a blank part of the second dialog) I cannot close this dialog (The second dialog) when I click OK or CANCEL button.
Why?
Part of Code:
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); }
The second Dialog is default code generated by MFC wizard.
Not sure I understand your question entirely . . . it sounds like you're trying to close the parent window when the message box is still shown?
If that's the case, the parent window owns the message box, and is not allowed to acquire focus until the message box is closed. You could try using
::MessageBox(NULL, L"oi", L"MessageBox", MB_OK);
instead of MessageBox, which will create a message box that allows you to focus back on the original window still (The :: means to use the global namespace version of MessageBox, which is the Windows native call as opposed to MFC).
链接地址: http://www.djcxy.com/p/39232.html上一篇: 如何在MFC中启动对话框?