Windows programming

Moderators: None (Apply to moderate this forum)
Number of threads: 3711
Number of posts: 9173

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
C++ - Please tell me how to setup global hook for WM_MDITILE Posted by FrankPaper on 25 Mar 2011 at 11:38 AM
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




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.