Question

I'm asking as the title says. Is it possible?

Since a MSG already contains all the things I need for a self-made event handler, I figured maybe I could make one. I'm asking this mostly to get rid of interpreted casting so I can use internal functions and classes inside my window class for performance. I also want to know if its possible to just get the MSG alone and do whatever I want with it.

Basically is there another way to get the window message, and then process it not similar to the general loops found in this thread?

EDIT: Currently I'm using GetMessage() function to get the MSG struct and use that in my own event handler, however I am not getting all the messages that I want with this. Is there anything else I should do?

Thank you in advanced.

Was it helpful?

Solution

Currently I'm using GetMessage() function to get the MSG struct

Which is the problem, GetMessage() only retrieves messages that were posted to the message queue. It does not detect messages that were sent with SendMessage(). Which bypasses the message queue and calls the window procedure directly.

You therefore must use WndProc to see all the messages for a window.

The subset of posted messages that go into the queue and thus returned by GetMessage() is a small one. In a nutshell, the input notification messages for mouse and keyboard and the low-priority messages (WM_PAINT, WM_TIMER, WM_QUIT). WM_ACTIVATE is always sent.

Replacing the WndProc of a window is certainly a common technique, it is called "sub-classing the window". Any C++ class library wrapper uses it to map messages to C++ methods. Best to not re-invent that wheel.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top