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!

Categories

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?
HINSTANCE hinst;

BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
//
// Capture the application instance of this module to pass to
// hook initialization.
//
if (hinst == NULL)
{
hinst = hModule;
}

case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}

return TRUE;
}
Any tips or suggestions?
Thanks

Sign In or Register to comment.