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.

see news://194.177.96.26/comp.os.ms-windows.programmer.win32
where it has been explained hundreds of times...

If you know how, it will be great that you explain it here. Newsgroups have no archives as I know. If I ask it here, it's because I found nothing. This will take you 5 minutes or less.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.