Catch windows messages of ANY app.

Posted on 1998-08-14
Last Modified: 2010-04-04

How can i catch windows messages of ANY application? For example, how can i cath the message WM_QUIT
sent from an application to Windows or vice versa.
Question by:migue77
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

Author Comment

ID: 1362102
Edited text of question

Accepted Solution

BoRiS earned 70 total points
ID: 1362103

You will have to use the SetWindowsHookEx API call and hook into a sytem wide DLL, as far as I can see...this seems to be the onl way to trap full system messages like WM_QUIT etc...

LVL 10

Expert Comment

ID: 1362104
You can also override the WndProc....and then you can trap the message there..

//Viktor Ivanov
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 10

Expert Comment

ID: 1362105
You can also override the WndProc....and then you can trap the message there..

//Viktor Ivanov

Expert Comment

ID: 1362106

If you have a specific message to catch than you can write a procedure to the form of your app like the following;
    form class declaration begins here...

    procedure MyHandler(var Msg: TMsg);message WM_QUIT;
or as Victor said you can override the WndProc to catch all the messages to your app.
But when overriding the WndProc be careful. Because all messages goes through this WndProc so be careful in regard of your application performance. Handle the message of your interest and call the inherited WndProc for the other messages.



Author Comment

ID: 1362107
You answer that question... so there are your points

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

739 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