Hi,

This concerns Microsoft Windows. I want to know when a window from other processes is made visible. Also, I want the handle of the window. I've tried to catch the message WM_SHOWWINDOW with SetWindowsHookEx(WH_GETMESSAGE, &MessageProc, g_hInstance, 0) but I receive no events ! The only events I receive is when I do a call to MessageBox after the call to SetWindowsHookEx. But the events only come from user32.dll. I call MessageBox to tell me that the call to SetWindowsHookEx is successful. Please, I need your help. Thank you.

You have to hook external objects using global hooks (those residing in a DLL). Process hooks can only be used with your own application's processes.

You have to hook external objects using global hooks (those residing in a DLL). Process hooks can only be used with your own application's processes.

Sorry, but I don't understand. My hook is already in a DLL, or do you mean that exists other hook functions that are more global to the system ? What I don't understand, is this is supposed to work according to Microsoft documentation :

SetWindowsHookEx
...
These events are associated either with a specific thread or with all threads in the same desktop as the calling thread.

I'm sorry, I mixed-up that last two arguments to SetWindowsHookEx() and thought you were installing a process hook.

The WM_SHOWWINDOW message is not a queued message --it is sent directly to the target window procedure. Hence, the WH_GETMESSAGE hook will never see it. You'll need to install a WH_CALLWNDPROC hook to catch it.

Annoying, isn't it?

(Sorry it took me this long to pay enough attention to answer your question...)

Thanks for your answer. Yes, I already tried WH_CALLWNDPROC with no luck. Please, see the file attachment to my first message.

Newsgroups are archived. For ever and ever. (But they are annoying to search.)

Yes, I already tried WH_CALLWNDPROC with no luck. Please, see the file attachment to my first message.

No, you tried WH_CALLWNDPROCRET, which is entirely different.

If you are still having problems I'll see if I can't compile your code myself and figure out what's wrong.

I also tried with WH_CALLWNDPROC and it doesn't work. Ok, I have no choice to send you the complete code, make what you want with it ;) It was supposed to be a simple program to practice and learn C/C++. It's developped under Visual Studio .NET 2002. I'll do cleanup when the hook will work.