I’ve a function callback to handle the window’s events like WM_SIZE. Now, how to pass the function callback to the open window? (It’s for a command-line application).
I’ve seen RegisterClassEx but I think that it’s used at creating a new window.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you want to handle windows messages for an existing window you have a couple options:
Subclassing. Each window has a “window proc” callback function (that you are referring to), and you can replace it using
SetWindowLongPtrwithGWLP_WNDPROC. Then in your own window proc, you need to forward messages to the original one that you replaced. There are some limitations though:Windows hooks, using
SetWindowsHookEx. Use this if you want to peek into the messages of other windows – you can see all messages for windows in a given thread, or system-wide. There are different types of hooks that allow you to catch different types of messages. This is a pretty heavy approach; a last resort so you don’t bog down the system unnecessarily.