Click here to Skip to main content
15,920,030 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi

I have a problem with my VC9 application when I exit it, and I found that the problem also occurs in the MFC sample 'VisualStudioDemo'. Problem is, so far I've only seen the problem occur on my PC; two of my colleagues don't get the problem at all.

Anyway here are the steps to reproduce in VisualStudioDemo:
1. Put a breakpoint in CVisualStudioDemoApp::ExitInstance()
2. Debug the application
3. In the application, create a new document, so there are two tabs open now
4. Exit the application. It doesn't hit the breakpoint.

It seems to be stuck in AfxInternalPumpMessage(). It does not have a problem exiting if I never create a new document in the application.

The fact that I am the only one so far who gets the problem tells me maybe something is wrong with my MFC DLLs but I would like a second opinion if possible! Even better would be confirmation that someone else gets the problem...

Thanks for any help.
Posted
Comments
Albert Holguin 28-Sep-11 13:44pm    
Is it stuck or did the application close and just not hit your breakpoint?
morrisecl 29-Sep-11 4:02am    
Hi Albert, it is stuck. The application does not close, ie it keeps debugging. Actually I found this morning that if I leave it long enough, it does hit the breakpoint and then close eventually (10-15 mins, haven't timed it yet though). Not sure if that's a useful clue or not.
barneyman 29-Sep-11 7:02am    
10 mins is the default COM exe server timeout; are you exposing any objects from it?
Albert Holguin 29-Sep-11 10:53am    
In the future, reply to my post if you want me to see it... that way I get an email notification... otherwise I won't know you replied.

I haven't used the demo app, but could it be that it has popped up a dialog asking if you want to save the document? May be the dialog is off screen or hidden in some way?
 
Share this answer
 
Comments
morrisecl 29-Sep-11 4:00am    
I don't think that is the case. The documents all seem to destruct OK, I think if it was asking to save one or both of them it would do that before destroying them.
Thanks very much for the tip though.
OK I got it.

I put PreTranslateMessage in the application class, and found it was getting hammered with WM_TIMER messages from the application toolbar (an CMFCToolbar).

I had a quick look in afxtoolbar.cpp and indeed there are timers set and killed in OnMouseMove (probably something about highlighting the button while the pointer is over it).

The timer ID is defined in afxtoolbar.cpp as AFX_ACCELERATOR_NOTIFY_EVENT = 20, which is the same as what I was getting in PreTranslateMessage as the lParam.

I didn't really want to muck about with the toolbar class but a quick Google of AFX_ACCELERATOR_NOTIFY_EVENT pointed me to this article:

http://connect.microsoft.com/VisualStudio/feedback/details/529735/mfc-feature-pack-cmfcmenubar-issue[^]

In there is a workaround which seems to work for me. I won't paste it here in case something changes at their end, but the link should get you there if you want to read about it.

Thanks very much everyone who made suggestions.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900