I am using MFC to write a GUI application. I chose dialog-based application, and put picture control, edit box and buttons on it. When the picture control is mapped to the class derived from CWnd using DDX_Control, all the message boxes (including default system message box pop up when you enter invalid input in the edit box) are hidden behind main dialog until you use "alt + tab" to bring them to front. If I map the picture control to the default CStatic class, the above problem disappeared. Do anyone has some hints to solve this problem? Thank you in advance for any help.
views:
561answers:
1
A:
Try calling
SetWindowPos( &CWnd::wndNoTopMost, 0, 0, 0, 0 SWP_NOMOVE | SWP_NOSIZE );
on the dialog window. MessageBox's will be created as a "top most" window and that should move the dialog window to behind any of these "top most" windows.
Goz
2009-08-12 21:02:38
Thanks for your reply. Here is the code in the dialog class by following you instructions:CWnd* pWnd = CWnd::FromHandle(HWND_NOTOPMOST); SetWindowPos( pWnd, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE );AfxMessageBox(msg, MB_OK | MB_ICONEXCLAMATION | MB_SETFOREGROUND | MB_TOPMOST | MB_TASKMODAL);The message box is still hidden before the dialog windows. Did I do something wrong here? Any help is appreciated.
Cougar_usa
2009-08-12 21:38:16
Im not sure if what you are doing, ebcause of my error, will work in. I have edited my original post. It still may not work but worth a shot :)
Goz
2009-08-12 21:46:09
unfortunately, it is still not working:)
Cougar_usa
2009-08-12 21:58:53
So what happens if you just call MessaageBox instead of AfxMessageBox? (ie CWnd::MessageBox). That way it should be a child of your dialog ...
Goz
2009-08-12 22:11:20
the problem still existed if I used ::MessageBox(this->GetSafeHwnd(), msg, "Application", MB_OK | MB_ICONEXCLAMATION | MB_SETFOREGROUND | MB_TOPMOST | MB_TASKMODAL);
Cougar_usa
2009-08-12 22:21:31
Then im sorry but im at a loss. Im off to bed so if i think of anything tomorrow morning ill suggest it :)
Goz
2009-08-12 22:23:55
I think the key is what happen when the control in the dialog is mapped to the class deriving from CWnd. I searched in the google, but didn't find any helpful info:( Anyway, thank you very much for your help.
Cougar_usa
2009-08-12 22:36:14
The problem is solved. I forget to invoke CWnd:OnPaint() in the OnPaint() of the CWnd derived class.
Cougar_usa
2009-08-24 18:28:10