Discussion:
Message Box is hidden behind the mainframe
(too old to reply)
s***@gmail.com
2008-03-04 12:18:19 UTC
Permalink
hello we use VC8 and develop an MFC SDI application ith several
modeless windows (panes). (we use Codejock Xtreme toolkit for UI)

we encounter the following bug which causes the application to hang:

whenever the user edits an edit box in one of our modeless windows,
and then presses alt-F4 to close the application (while still editing
the edit box), the messagebox (prompting to save the document before
closing) appears HIDDEN behind the mainframe. The application is not
responding (because the messagebox is still open) but the message box
is not shown and the user has no indication that a messagebox has been
opened. Only when pressing Alt, or cycling windows with alt tab, the
message appears.


I use something similar to the folloing code :



BOOL confirm(HWND hWnd, bool OnExit){
...
MessageBox(hWnd, "Save before exit?"", "Save?", MB_YESNOCANCEL |
MB_ICONQUESTION | MB_TOPMOST|MB_TASKMODAL))


now, I have tried MB_SETFOREGROUND, MB_TASKMODAL, and other
switches, tried AfxMessageBox() instead, tried passing NULL or a
mainframe pointer as a window handle, nothing seems to fix this...
Anyone has any idea how to handle this??

10x a lot
Jonathan Wood
2008-03-04 16:50:55 UTC
Permalink
So what is hWnd? It should appear in front of the window you specify as the
parent.
--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
Post by s***@gmail.com
hello we use VC8 and develop an MFC SDI application ith several
modeless windows (panes). (we use Codejock Xtreme toolkit for UI)
whenever the user edits an edit box in one of our modeless windows,
and then presses alt-F4 to close the application (while still editing
the edit box), the messagebox (prompting to save the document before
closing) appears HIDDEN behind the mainframe. The application is not
responding (because the messagebox is still open) but the message box
is not shown and the user has no indication that a messagebox has been
opened. Only when pressing Alt, or cycling windows with alt tab, the
message appears.
BOOL confirm(HWND hWnd, bool OnExit){
...
MessageBox(hWnd, "Save before exit?"", "Save?", MB_YESNOCANCEL |
MB_ICONQUESTION | MB_TOPMOST|MB_TASKMODAL))
now, I have tried MB_SETFOREGROUND, MB_TASKMODAL, and other
switches, tried AfxMessageBox() instead, tried passing NULL or a
mainframe pointer as a window handle, nothing seems to fix this...
Anyone has any idea how to handle this??
10x a lot
Joseph M. Newcomer
2008-03-04 17:00:42 UTC
Permalink
See below...
Post by s***@gmail.com
hello we use VC8 and develop an MFC SDI application ith several
modeless windows (panes). (we use Codejock Xtreme toolkit for UI)
whenever the user edits an edit box in one of our modeless windows,
and then presses alt-F4 to close the application (while still editing
the edit box), the messagebox (prompting to save the document before
closing) appears HIDDEN behind the mainframe. The application is not
responding (because the messagebox is still open) but the message box
is not shown and the user has no indication that a messagebox has been
opened. Only when pressing Alt, or cycling windows with alt tab, the
message appears.
BOOL confirm(HWND hWnd, bool OnExit){
****
What is the value of hWnd at this point? It appears that it is NULL.

Why are you rolling your own handler? If you simply call the SetModifiedFlag method of
the CDocument, the SDI framework handles this for you.
****
Post by s***@gmail.com
...
MessageBox(hWnd, "Save before exit?"", "Save?", MB_YESNOCANCEL |
MB_ICONQUESTION | MB_TOPMOST|MB_TASKMODAL))
****
Why are you even bothering to pass in a window handle and why are you calling
::MessageBox? Why not ignore the window handle and call AfxMessageBox, which will do the
right thing?

I've never seen anyone use the MB_TASKMODAL flag.

Put whitespace around the | in all places to make the code more readable
Post by s***@gmail.com
now, I have tried MB_SETFOREGROUND, MB_TASKMODAL, and other
switches, tried AfxMessageBox() instead, tried passing NULL or a
mainframe pointer as a window handle, nothing seems to fix this...
Anyone has any idea how to handle this??
****
NULL will definitely CAUSE the problem. AfxMessageBox should work, but it appears this is
a global function, which makes no sense. But again, you appear to be duplicating what the
framework already implements correctly, so why are you writing your own handler?

Whenever you see a messagebox coming up behind the mainframe, it means you have somehow
managed to use the desktop as the parent, and the usual cause of this is a NULL parent
handle. I've never had a problem with this, but among other things, it depends upon when
in the process of shutting down you manage to issue this call. Since you showed us code
and NO CONTEXT in which the code is called, it is impossible to guess what you did wrong,
but I'd suggest throwing all this code out and using the built-in mechanism.
joe
****
Post by s***@gmail.com
10x a lot
Joseph M. Newcomer [MVP]
email: ***@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
PvdG42
2008-03-04 17:05:17 UTC
Permalink
Post by s***@gmail.com
hello we use VC8 and develop an MFC SDI application ith several
modeless windows (panes). (we use Codejock Xtreme toolkit for UI)
whenever the user edits an edit box in one of our modeless windows,
and then presses alt-F4 to close the application (while still editing
the edit box), the messagebox (prompting to save the document before
closing) appears HIDDEN behind the mainframe. The application is not
responding (because the messagebox is still open) but the message box
is not shown and the user has no indication that a messagebox has been
opened. Only when pressing Alt, or cycling windows with alt tab, the
message appears.
BOOL confirm(HWND hWnd, bool OnExit){
...
MessageBox(hWnd, "Save before exit?"", "Save?", MB_YESNOCANCEL |
MB_ICONQUESTION | MB_TOPMOST|MB_TASKMODAL))
now, I have tried MB_SETFOREGROUND, MB_TASKMODAL, and other
switches, tried AfxMessageBox() instead, tried passing NULL or a
mainframe pointer as a window handle, nothing seems to fix this...
Anyone has any idea how to handle this??
10x a lot
See what happens is you do something simple like this:

AfxMessageBox(_T("Am I modal?"));

If it appears, there's something wrong with the arguments you used. If it is
still hidden, I'd suspect the third party UI tool.
s***@gmail.com
2008-03-05 10:44:06 UTC
Permalink
Post by PvdG42
Post by s***@gmail.com
hello we use VC8 and develop an MFC SDI application ith several
modeless windows (panes). (we use Codejock Xtreme toolkit for UI)
whenever the user edits an edit box in one of our modeless windows,
and then presses alt-F4 to close the application (while still editing
the edit box), the messagebox (prompting to save the document before
closing) appears HIDDEN behind the mainframe. The application is not
responding (because the messagebox is still open) but the message box
is not shown and the user has no indication that a messagebox has been
opened. Only when pressing Alt, or cycling windows with alt tab, the
message appears.
BOOL confirm(HWND hWnd, bool OnExit){
...
MessageBox(hWnd, "Save before exit?"", "Save?", MB_YESNOCANCEL |
MB_ICONQUESTION | MB_TOPMOST|MB_TASKMODAL))
now, I have tried MB_SETFOREGROUND,  MB_TASKMODAL,  and other
switches, tried AfxMessageBox() instead, tried passing NULL or a
mainframe pointer as a window handle, nothing seems to fix this...
Anyone has any idea how to handle this??
10x a lot
AfxMessageBox(_T("Am I modal?"));
If it appears, there's something wrong with the arguments you used. If it is
still hidden, I'd suspect the third party UI tool.- Hide quoted text -
- Show quoted text -
thanks for the help

ok I should clarify a few things I tried
Cwnd::MessageBox()
::MessageBox()
AfxMessageBox()
I tried sending hWnd as NULL, as the MAINFRAME
I tried messing with the MB switches
I even tried ASSERT(0)

all of these are shown behind the application

as I have already mentioned this problem only occurs when the user is
closing the application WHILE editing an edit box in a pane. In other
cases the messagebox is shown fine so this seems to be somehow causing
the problem

BTW this is code is not mine and it is old. possibly written
originally in C w/o MFC

Thank you
s***@gmail.com
2008-03-06 10:22:52 UTC
Permalink
Post by s***@gmail.com
Post by PvdG42
Post by s***@gmail.com
hello we use VC8 and develop an MFC SDI application ith several
modeless windows (panes). (we use Codejock Xtreme toolkit for UI)
whenever the user edits an edit box in one of our modeless windows,
and then presses alt-F4 to close the application (while still editing
the edit box), the messagebox (prompting to save the document before
closing) appears HIDDEN behind the mainframe. The application is not
responding (because the messagebox is still open) but the message box
is not shown and the user has no indication that a messagebox has been
opened. Only when pressing Alt, or cycling windows with alt tab, the
message appears.
BOOL confirm(HWND hWnd, bool OnExit){
...
MessageBox(hWnd, "Save before exit?"", "Save?", MB_YESNOCANCEL |
MB_ICONQUESTION | MB_TOPMOST|MB_TASKMODAL))
now, I have tried MB_SETFOREGROUND,  MB_TASKMODAL,  and other
switches, tried AfxMessageBox() instead, tried passing NULL or a
mainframe pointer as a window handle, nothing seems to fix this...
Anyone has any idea how to handle this??
10x a lot
AfxMessageBox(_T("Am I modal?"));
If it appears, there's something wrong with the arguments you used. If it is
still hidden, I'd suspect the third party UI tool.- Hide quoted text -
- Show quoted text -
thanks for the help
ok I should clarify a few things I tried
Cwnd::MessageBox()
::MessageBox()
AfxMessageBox()
I tried sending hWnd as NULL, as the MAINFRAME
I tried messing with the MB switches
I even tried ASSERT(0)
all of these are shown behind the application
as I have already mentioned this problem only occurs when the user is
closing the application WHILE editing an edit box in a pane. In other
cases the messagebox is shown fine so this seems to be somehow causing
the problem
BTW this is code is not mine and it is old. possibly written
originally in C w/o MFC
Thank you- Hide quoted text -
- Show quoted text -
I suspect that when a messagebox is thhrown when editbox in a pane is
edited, tha pane somehow causaes it to be hidden.
(the panes are 3rd party GUI )
f***@gmail.com
2014-03-20 12:33:21 UTC
Permalink
Hello,

Can you tell me if you have found a solution to resolve this problem because we have it ?

Thank you
Best regards
Post by s***@gmail.com
Post by PvdG42
Post by s***@gmail.com
hello we use VC8 and develop an MFC SDI application ith several
modeless windows (panes). (we use Codejock Xtreme toolkit for UI)
whenever the user edits an edit box in one of our modeless windows,
and then presses alt-F4 to close the application (while still editing
the edit box), the messagebox (prompting to save the document before
closing) appears HIDDEN behind the mainframe. The application is not
responding (because the messagebox is still open) but the message box
is not shown and the user has no indication that a messagebox has been
opened. Only when pressing Alt, or cycling windows with alt tab, the
message appears.
BOOL confirm(HWND hWnd, bool OnExit){
...
MessageBox(hWnd, "Save before exit?"", "Save?", MB_YESNOCANCEL |
MB_ICONQUESTION | MB_TOPMOST|MB_TASKMODAL))
now, I have tried MB_SETFOREGROUND,  MB_TASKMODAL,  and other
switches, tried AfxMessageBox() instead, tried passing NULL or a
mainframe pointer as a window handle, nothing seems to fix this...
Anyone has any idea how to handle this??
10x a lot
AfxMessageBox(_T("Am I modal?"));
If it appears, there's something wrong with the arguments you used. If it is
still hidden, I'd suspect the third party UI tool.- Hide quoted text -
- Show quoted text -
thanks for the help
ok I should clarify a few things I tried
Cwnd::MessageBox()
::MessageBox()
AfxMessageBox()
I tried sending hWnd as NULL, as the MAINFRAME
I tried messing with the MB switches
I even tried ASSERT(0)
all of these are shown behind the application
as I have already mentioned this problem only occurs when the user is
closing the application WHILE editing an edit box in a pane. In other
cases the messagebox is shown fine so this seems to be somehow causing
the problem
BTW this is code is not mine and it is old. possibly written
originally in C w/o MFC
Thank you
Continue reading on narkive:
Loading...