Solved

Need to get all messages in applicationat a high level...

Posted on 1998-08-26
5
353 Views
Last Modified: 2013-12-03
This is some background description of what is going on in my application, the actual bit I am trying get an answer for follows it:

I have an application which communicates with an OLE server, which is a Netscape plugin, through OLE automation.  The problem I am running into is that when I press the back button in the browser the plugin shuts down and my application which is running and doing the drawing for the plugin can be running and in a suspended state (say with a message box up) but the OLE destruction causes the application to become re-entrant (I get into the main application message loop even though part of it is still in a modal dalog box).  When a user then later decides to close the message box the memory from underneath it has been destroyed because of the destruction that occurs when the OLE calls make the application re-entrant.  What I do right now is override PreTranslate message to handle all application messages and set a busy flag while ::TranslateMessage and ::DispatchMessage are active and then I clear it later.

I was assuming that every message in my application had to go through PreTranslate message, so I could basically determine whenever anything was going on in my app and when that exited I could then free up the memory.  Unfortunately when looking at the call stack during some of the bad memory accesses in my app following the dismissal of a modal dialog that was up before the plugin shutdown I see my application having entered the point the the main AfxWndProc without PreTranslateMessage on the stack.

I can only assume this means that messages are being sent more directly to a window in my application, so my question is this: How can I provide a handler for my app that can be notified whenever any message is going on.  If I override the main windows message handler and insert my busy checking will that cover it?  Can I override the AfxWndProc and if so how?  I want to know when messages in my main apps window or any of its child windows are ocurring so I don't free things up until they have finished.  

If you have a solution to my problem or a partial solution to the problem, please let me know ASAP.
0
Comment
Question by:woodsnick
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
5 Comments
 
LVL 2

Accepted Solution

by:
duneram earned 200 total points
ID: 1413937
Install a hook using SetWindowsEx and WH_MESSAGE

That will catch all messages.  YOu can do it app wide or system wide.  You will catch all messages depending on how you set it up.

0
 
LVL 2

Expert Comment

by:duneram
ID: 1413938
its setwindowshookex
0
 
LVL 2

Expert Comment

by:duneram
ID: 1413939
You can get samples of it at http://support.microsoft.com/support/kb/articles/q81/3/32.asp

article  Q81332 and Q74547

in 32 bits the usage of hooks (high level) are pretty much the same with some exceptions.

0
 
LVL 2

Expert Comment

by:duneram
ID: 1413940
Use this parameter:
WH_GETMESSAGE Installs a hook procedure that monitors messages posted to a message queue.  It can be a system wide monitor or just an application.  SetWindowsHookEx is the Key API.
0
 
LVL 2

Expert Comment

by:duneram
ID: 1413941
if you use the WH_MSGFILTER parameter, it installs a hook procedure that monitors messages generated as a result of an input event in a dialog box, message box, menu, or scroll bar.  
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question