Message Box is hidden behind the mainframe

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
0
samocha (3)
3/4/2008 12:18:19 PM
vc.mfc 33608 articles. 0 followers. Follow

5 Replies
759 Views

Similar Articles

[PageSpeed] 30

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

<samocha@gmail.com> wrote in message 
news:b8fb860e-39be-4610-94d5-6c365bba83bd@m34g2000hsc.googlegroups.com...
> 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 

0
jwood (1292)
3/4/2008 4:50:55 PM
See below...
On Tue, 4 Mar 2008 04:18:19 -0800 (PST), samocha@gmail.com wrote:

>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){
****
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.
****
>...
>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
>
>
>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
****
>
>10x a lot
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15974)
3/4/2008 5:00:42 PM
<samocha@gmail.com> wrote in message 
news:b8fb860e-39be-4610-94d5-6c365bba83bd@m34g2000hsc.googlegroups.com...
> 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

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.

0
pvdg (5)
3/4/2008 5:05:17 PM
On Mar 4, 7:05=A0pm, "PvdG42" <p...@toadstool.edu> wrote:
> <samo...@gmail.com> wrote in message
>
> news:b8fb860e-39be-4610-94d5-6c365bba83bd@m34g2000hsc.googlegroups.com...
>
>
>
>
>
> > 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, =A0MB_TASKMODAL, =A0and 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.- 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
0
samocha (3)
3/5/2008 10:44:06 AM
On Mar 5, 12:44=A0pm, samo...@gmail.com wrote:
> On Mar 4, 7:05=A0pm, "PvdG42" <p...@toadstool.edu> wrote:
>
>
>
>
>
> > <samo...@gmail.com> wrote in message
>
> >news:b8fb860e-39be-4610-94d5-6c365bba83bd@m34g2000hsc.googlegroups.com...=

>
> > > 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, =A0MB_TASKMODAL, =A0and 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 i=
t 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 )
0
samocha (3)
3/6/2008 10:22:52 AM
Reply:

Similar Artilces:

Filling drop down box
hi, I have a drop down box in a cell. Based on a value of anohter cell I have to fill my drop down box. what i mean is, say if GreeNPackage is "No" then I want the drop down box to fill a range of values. But if the GreeNPackage is "Yes" then I want the drop down box to fill another set of values. how can i do this? plenty of thanks See reply in .Functions Biff >-----Original Message----- >hi, > >I have a drop down box in a cell. Based on a value of >anohter cell I have to fill my drop down box. what i mean >is, say if >GreeNPackage is ...

data from a modeless dialog box to its parent
I need to post a text data from a modeless dialog box to its parent which is itself a dialog based application. Since it should be a large text data a simple Windows message won't be good. What is the right way to do that? Thanks Gil If you are sure the data will stay current you can post the address of the data (as a pointer) in a windows message to the parent. If you want to be really sure use SendMessage() which will wait until the parent gets the message before returning. You could call a function or copy the data to a variable in the parent dialog, but that could be dang...

Mail merge recipient dialog box
Why are the "edit" and "refresh" buttons at the bottom of the mail merge recipient dialog box grayed out? They were available in the last Word version but I cannot figure how to access them in 7 to add to or correct my mailing list. In Word 2007, the first thing you have to do is select the name of the data source in the box at the bottom left of the dialog box. Then, depending on the type of data source, the Edit and Refresh buttons may be ungreyed. [FWIW the same dialog is used by MS Publisher, where they allow multiple data sources, requiring you to ...

Message From Field in Folder
When viewing the list of my new messages, is there a way to see the email address of the sender instead of the alias before I open it? In the From column I see "John". When I open the email I see "John <john@johnsemail.com>". I want to see the "john@johnsemail.com" before I open it so I can tell the difference between emails from "Microsoft Support <yourfu@edifyouopenedthis.com>" and "Microsoft Support <someguywhosreally@microsoft.com>" I am currently using outlook 2002 and 2003 alternately based on my mood. Mike If you ...

Two messages at no data in a report
I have a form with a Click-Buttom for opening a report. In the design mode of the report I have used "At no data" and there included a Messega Box saying "Sorry-there is no data in this report". When having no data i the report and clicking on my buttom in the form I will hav 2 messages. The first one is from my message box "Sorry ...." The second one is from the error handling for the buttom saying "Instructio Open report cancelled" (Translated from Swedish "Instruktionen PoenReport avbröts). A part of the error code for the buttom is...

How to avoid excel warning message
Hi, When calling excel file from Ms-Access it display security warning. How to programmatically supress this warning? On Oct 25, 2:35 am, Sivanand <Sivan...@discussions.microsoft.com> wrote: > Hi, > When calling excel file from Ms-Access it display security warning. How to > programmatically supress this warning? If you are using a command button with a hyperlink to access your excel file, instead why not try the FollowHyperlink method by using the command button's on click event: Private Sub cmdHyperlink_Click() Application.FollowHyperlink "Hyperlink Address&quo...

how to format :send picture with message: as a default
each time i sent a graphic i must go to the format and click "send picture with message." how do I make this a default so it is there permanently.I am running on a Windows XP and am using Outlook Express for my mail. LYNNY <LYNNY@discussions.microsoft.com> wrote: > each time i sent a graphic i must go to the format and click "send > picture with message." how do I make this a default so it is there > permanently.I am running on a Windows XP and am using Outlook Express > for my mail. Ask in an Outlook Express newsgroup. -- Brian Tillman ...

attachments in inbound messages do not decode #2
I have a problem with an exchange 5.5 server (on NT 4 box). All of a sudden message attachments from a specific outside domain do not decode. See below the attachment just shows up has junk. How do you fix this? Other interesting thing if I forward (either internal or external) the message to anyone the attachment works fine. I have searched but haven't found any pertinent ports. Paul ------------------------------------------------------------------------------------------------------------------- > -----Original Message----- > From: Nolan, Pati > Sent: Friday, November 11...

Message Stuck in Outbox to Only One Particular Email Address
Hi: I have Outlook 2007 and have been using it for about 2 months or so. I have encountered a problem with sending emails. I have sent emails to a particular email address (WinTips-Tricks@yahoogroups.com ) and the emails get stuck in the outbox. The CPU usage is very high (about 76%) and the taskbar icon flashes furiously. If I look in the outbox, the email is also doing a staccato flash. At the bottom of Outlook the send says complete, yet the flashing taskbar icon, and flashing email in the outbox remain. After awhile (about 2-3 minutes) this stops, but the email remains in the outbox....

Messages stuck in Queue with status Active and eventually fail.
I have an exchange 2000 server with SP3. The scenario is this; Everything has been functioning great except emailing to AOL, so I setup a smart host to use our ISP's smtp server. Well, they are getting flagged as open relay and the mail is rejected. So I had them setup a reverse dns lookup for our IP so I could send mail directly. I found a site that allows me to check RBL's and we came up good on about 25 of them, so we aren't black listed. Now we can email aol users without any problems, but all of a sudden, I can't get the server to deliver mail to other exchang...

Messages stuck in Outbox + Heavy CPU load Outlook 2007
Hi, I am using Outlook 2007 with Windows Vista Ultimate. I have a very annoying problem. On a random messages, Outlook "decides" that a certain message will not leave the outbox whatsoever, even if I will write the same message again and again. It happens usually with attachments (usually small ones) but not always. This is what is happening usually: I am writing the message as usual, and trying to send it. In the lower corner, Outlook informs that send/receive was completed successfully but the message remains in the outbox, and somehow blinks a little (if I can describe it ...

Save a Copy/Overwrite changes dialog box
All of a sudden, this dialog box pops up every time I want to save something in Excel 2002. The box says, "The file '<file name>' may have been changed by another user since you last saved it. In that case, what do you want to do? __ Save a Copy __ Overwrite changes even though I'm the only user that's changed anything in the past 3 years. The shared workbook command has not been changed at all, so that can't be the problem. The settings are the same as the ones I have at home for personal spreadsheets that don't have this dialog box. Help! Than...

How to leave a copy of messages on server using Outlook 2000 and 2002
I am using Outlook 2000 with our company exchange server, how do I setup outlook so it leaves a copy of messages on the server so I can use multiple computers to access email. I have spent an hour but can't the setting to do this. thx Rajesh By default, when you set up Outlook to connect to an Exchange mailbox, it opens the full mailbox (MAPI connection) - doesn't download mail (POP connection). So unless you are using POP mail, or a PST file for delivery, your mail should stay in the Exchange mailbox (which is the best place) and you can access it from multiple computers. Proba...

Help: message "Requesting data from Exchange Server"
Has anyone figure out why we receive the pop-up message "Requesting data from Exchange Server" when we try to open an email in outlook? We are using Exchange 2000. Is there a parameter we can change to fix this issue? "Kenny" <anonymous@discussions.microsoft.com> wrote: >Has anyone figure out why we receive the pop-up >message "Requesting data from Exchange Server" when we >try to open an email in outlook? We are using Exchange >2000. > >Is there a parameter we can change to fix this issue? Depends to a greater or lesser extent ...

Creating a new default message template
I have a email template that I want to make the default. In other words, when you click on New to create a new email, I want the message template that I have created to come up as the default. Does anyone know how to do this? What you are proposing is a very bad idea. Using a custom form as the = default for new messages will guarantee that non-Outlook recipients = won't be able to read attachments you send.=20 I'd suggest that you back up and explain what functionality you were = hoping to add by changing the message form, and in what version of = Outlook.=20 --=20 Sue Mosher, ...

Outlook message bodies Blank
When I open my email in outlook the body is empty. I seem to remember somethig about my AVG doing something. Any Ideas how to fix this? Thanks Disable the email scanning feature in your anti-virus software. (For example, in AVG, uncheck certify under the email scanning settings.) You'll still be protected by its other features and by Outlook's own security, and new messages shouldn't lose their bodies. Messages you've already received, though, can't be repaired. Hal -- Hal Hostetler, CPBE -- hhh@kvoa.com Senior Engineer/MIS -- MS MVP-Print/Imaging -- WA7BGX http://w...

CDO eMail messages not working from FoxPro since installing KB8929
We installed the Exchange 2000 Update (KB892986) and since then our code that creates CDO eMails errors out with the following message: "OLE IDispatch exception code 0 from CDO.Message.1: The transport lost its connection to the server." We are planning to reverse thes updates over the weekend. Does anyone know a better way around this? ...

'Signature for new messages' which won't work
Hi, I have Outlook 2003 and if I go to Tools>Options>Mail Format I see I can choose a signature for new messages. I have 3 e-mail accounts set up, and have set a new message signature for each one, e.g.: 1) Home > Sig 1 (default) 2) Work > Sig 2 3) Play > Sig 3 However when I try to create a new e-mail message, it seems impossible to automatically start a new e-mail using my Work or Play accounts, and therefore have the signature automatically entered. So what is the point of this feature if there is no way to use it? I'm sure I'm missing so...

combo box list updating
Hi - I would like my combo box list to change base on the value of A1. That is, I have its input range being B1:F1 - "Year 1", " Year 2" etc. Example: -If cell A1 is the value "10" then the combo box default list item would be "Year 1" (which is cell "B1") -If cell A1 is the value "20" then the combo box default list item would be "Year 2" (which is cell "C1") ETC... Thanks for your help - Jim A ...

"Find a contact box" problem
Hi. I�m having problems with the �Find a contact� box on the Standard toolbar. Previously, I would type in a name and the search would pull up name/s from the Outlook Contacts folder first then, if the name is not in the Contacts folder, it would pull up name/s from the Global Address List if any. Now, when I type in a name, the search only pulls up name/s from the Global Address List. The search does not include the Contacts folder although there are entries in the Contacts folder. The problem started after I transferred a couple of Contacts subfolders to another pst file. How do I fix the p...

Not able to view activities
Hi, I have a MS CRM 3.0 VPC running. I have allocated 1GB memory as recommended. However, whenever I try opening Activities(any entity for that matter), it is throwing an error dialog "An error has occured. For more information, contact you system administrator." I checked the event viewer, but there is no information about any error/exception. I searched for the CRM log, but couldn't locate it. Pls help me fix this issue. Thanks and Regards, Mahalax. ...

need help with list box?
Hi I have a huge table of about 20000 records. how can I restrict entry for a few columns. I am new to excel programming. For example. I have a list of colors (red, green, blue) that I want to go under the Color column. how can I allow the user to click on a pulldown or list box similar to ms access for each cell. thanks in advance. Hi you could use 'Data - Validation'. See: http://www.contextures.com/xlDataVal01.html >-----Original Message----- >Hi > >I have a huge table of about 20000 records. how can I restrict entry for a >few columns. >I am new to exc...

Check box question 04-23-07
I have a form with a check box used to indicate if a receipt is voided or not. What I'm trying to do is go to a new record after the checkbox is marked. I have the following code in place and it works. Kinda. The problem is that if I then go back and UNCHECK the check box, it sends me to a new record again. Here's the code: Private Sub Check43_AfterUpdate() If Ckeck43 = Yes Then DoCmd.GoToRecord , , acNewRec Thanks for any help! End Sub The following works fine for me. If Me.Check3 = True Then DoCmd.GoToRecord , , acNewRec so try If Ckeck43 = True Then DoCmd.GoToRecor...

How do I remove a hidden space in Excel cells
Not sure if this is an Excel or Word problem... I am doing a mail merge in Word (envelopes). I am pulling my data (name, address, cit/state/zip) from an Excel .xls I created. In mail merge, I select envelopes and go through all the steps. I use the Address Block for the delivery address. However, when it pulls the data over, the name line (first line of address block) is indented by one space. No matter what I do (place cursor at indent and use backspace or place cursor at next two correct lines and add a space), the change doesn't take place. I've checked all the tabs as...

Some contacts don't show on drop down box when addressing email
I was using Outlook Express, my computer motherboard died, got new computer with Windows 7, trying to learn Outlook 2003. The computer tech from my husband's office put Outlook 2003 on the new computer and somehow transferred the addresses that I had in Outlook Express. I do not know what method he used to get the addresses into Outlook 2003. Some things carried over just fine, some things didn't, i.e. a group list of my subdivision property owners, so I had to re-make that distribution list. When I want to email my daughter, her name or email address is not s...