?
Solved

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

Posted on 1998-08-26
5
Medium Priority
?
361 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 600 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
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…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

752 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