C++ - Please tell me how to setup global hook for WM_MDITILE - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

C++ - Please tell me how to setup global hook for WM_MDITILE

I know everyone is off to great mobile or web type work. Well, I'm stuck here on some good old C++. Here's whats bugging me.

I want my application to do a certain thing when the user presses the menu "Tile Vertically" in another app (in another process). (Many apps have a menu "Windows" and underneath that is a sub menu "Tile Vertically"). I'm under the assumption that I need to setup a global hook using SetWindowsHookEx. I tried doing that using "WH_CALLWNDPROC" and was only able to hook to "in process" messages, not "out of process". I tried WH_GETMESSAGE as well. I tried catching WM_SIZE, that also did not work out of process. In fact, even in process, WM_SIZE didn't work on all windows , only on some of them.
So now there are a few questions:
1- What is the right type of hook (WH_CALLWNDPROC or WH_GETMESSAGE or perhaps one of the other hook types that can be used)?
2- How do I get it to pick up out of process messages?
3- Any tips where I can get sample hook code for WM_MDITILE?
4- I tried doing a keyboard hook and that worked, why doesn't this work?
5- I'm using a win 32 dll with the DllMain code below. Is there anything wrong with it?

DWORD ul_reason_for_call,
LPVOID lpReserved
switch (ul_reason_for_call)
// Capture the application instance of this module to pass to
// hook initialization.
if (hinst == NULL)
hinst = hModule;


return TRUE;
Any tips or suggestions?

Sign In or Register to comment.