jmasterx
jmasterx

Reputation: 54123

Receive messages from a window you only have the HWND of?

I'm using an API for games. It creates the window for me but there are a few messages I'd like to do something with. For example, when the screen is resizing I want to display a black screen. Essentially, I have the HWND of my main window and would like to listen to the messages and have them go through my custom WndProc before or after they are processed, I just want to know when the window receives messages like WM_SIZE or something.

Is there an API for this?

Thanks

Upvotes: 2

Views: 1265

Answers (1)

minjang
minjang

Reputation: 9060

If you are in the same process with the window that you want to intercept WM_SIZE, you can simply replace WndProc by SetWindowLongPtr with GWLP_WNDPROC. Note that you must pass the other messages to the original WndProc.

However, if you are in the different process, then you need to find a way using hooks such as SetWindowsHookEx

Upvotes: 7

Related Questions