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

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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

Title # Comments Views Activity
LAN or WAN ? 11 95
tvirtualstringtree freeze when load too manny images 10 71
how can i search if string exist in array ? 3 63
PHP preg_replace code convert to Delphi 14 66
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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
In a recent question ( here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

840 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