[Last Call] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 224
  • Last Modified:

A brief understanding on how capturing windows messages work

My aim is to handle selected windows messages. I've been navigating through Internet and they are all very mixed up. I would be grateful if someone will link me a tutorial or help me understand how the procedure works since i'm completely lost.
  • 2
1 Solution
You want to capture windows messages in your MFC application? You can handle messages to the current window you're conerned with. Look at the documentation for CWnd:


Most of the OnXXX() member functions are mapped message handlers. For instance:


will fire when the user left clicks in that window. Are you developing for MFC, or just plain win32? And what messages do you want to handle? If you give this information I can give specific examples for you.

... Or are you interested in capturing/monitoring window messages in *other applications* (other than the programs you write yourself).  The techniques are very different.
afos21Author Commented:
actually, my purpose is to write a mouse recorder application. I wasn't given any restrictions. I'm free to choose any programming language i want. They told me is much easier to do it with java but i choosed c++ because i'm more familiar with
You need to write what is called a Windows Hook.  In order to record mouse clicks and movement in an external APP, it must be a global hook  and it must reside in a DLL.

Here is a link to some source code that does waht you want

Here is one answer from another question at EE:
And here is an EE search to a bunch of related questions:

Here is the MSDN topic at Microsoft:

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now