Closing AfxMessageBox
-
Hi All, I have a dialog (say CMyDlg) from which i show a message box(AfxMessageBox). I call the DoModal() of the CMyDlg. After a while with the same instance of CMyDlg i close the dialog by calling EndDialog. My Question:: 1. If the message box is shown, is it possible to close that first and then close the CMyDlg. Main Condition :(( : I am not supposed to use the ::FindWindow for the AfxMessageBox since the message box title will keep changing with time. Please help. Regards Sunil
Sunil
-
Hi All, I have a dialog (say CMyDlg) from which i show a message box(AfxMessageBox). I call the DoModal() of the CMyDlg. After a while with the same instance of CMyDlg i close the dialog by calling EndDialog. My Question:: 1. If the message box is shown, is it possible to close that first and then close the CMyDlg. Main Condition :(( : I am not supposed to use the ::FindWindow for the AfxMessageBox since the message box title will keep changing with time. Please help. Regards Sunil
Sunil
You're going to struggle. But you don't *have* to use MessageBox - there's nothing stopping you using a second dialog that you designed and have code control over - then you can post messages (ie, WM_COMMAND/IDCANCEL, WM_CLOSE) more easily. MessageBox is a very useful straitjacket, but it still restricts you. Iain.
Plz sir... CPallini CPallini abuz drugz, plz plz help urgent.
-
Hi All, I have a dialog (say CMyDlg) from which i show a message box(AfxMessageBox). I call the DoModal() of the CMyDlg. After a while with the same instance of CMyDlg i close the dialog by calling EndDialog. My Question:: 1. If the message box is shown, is it possible to close that first and then close the CMyDlg. Main Condition :(( : I am not supposed to use the ::FindWindow for the AfxMessageBox since the message box title will keep changing with time. Please help. Regards Sunil
Sunil
sunilpv1982 wrote:
1. If the message box is shown, is it possible to close that first and then close the CMyDlg.
Possible, maybe, but it doesn't make much sense. Why are trying to use modal dialogs modelessly?
sunilpv1982 wrote:
I am not supposed to use the ::FindWindow for the AfxMessageBox since the message box title will keep changing with time.
How did you find the window to change its title? Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
sunilpv1982 wrote:
1. If the message box is shown, is it possible to close that first and then close the CMyDlg.
Possible, maybe, but it doesn't make much sense. Why are trying to use modal dialogs modelessly?
sunilpv1982 wrote:
I am not supposed to use the ::FindWindow for the AfxMessageBox since the message box title will keep changing with time.
How did you find the window to change its title? Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
Hi Mark, Thanks for replying.
Mark Salsbery wrote:
Possible, maybe, but it doesn't make much sense. Why are trying to use modal dialogs modelessly?
If i use CMyDlg in a modeless fashion(also providing a parent window handle), the user will still be able to control the parent window. I want the user to respond within a timeout value. If there is no response then close the CMyDlg window and any message boxes opened within CMyDlg.
Mark Salsbery wrote:
How did you find the window to change its title?
AfxMessageBox/MessageBox has a title. The ::FindWindow API gives the handle to the window by passing the title. In my case the title displayed in the MessageBox keeps changing with time(as a result of some SQL query).
Sunil
-
Hi Mark, Thanks for replying.
Mark Salsbery wrote:
Possible, maybe, but it doesn't make much sense. Why are trying to use modal dialogs modelessly?
If i use CMyDlg in a modeless fashion(also providing a parent window handle), the user will still be able to control the parent window. I want the user to respond within a timeout value. If there is no response then close the CMyDlg window and any message boxes opened within CMyDlg.
Mark Salsbery wrote:
How did you find the window to change its title?
AfxMessageBox/MessageBox has a title. The ::FindWindow API gives the handle to the window by passing the title. In my case the title displayed in the MessageBox keeps changing with time(as a result of some SQL query).
Sunil
sunilpv1982 wrote:
the user will still be able to control the parent window
You can disable the parent window. That's what MFC does to simulate a modal dialog. Mark
Mark Salsbery Microsoft MVP - Visual C++ :java: