Click to See Complete Forum and Search --> : Problem with SetWindowsHookEx


PerryBruins
November 17th, 2003, 06:07 AM
Hi all,

I am trying to set a hook for CallWndProc in order to catch the WM_PAINT message. Now, everything works, setting the hook, loading the dll, unhooking, etc, but I never seem to get a WM_PAINT message.

Does someone know why this is?

Second questions is, how can I get the bitmap of the window being painted to send to another application? As you can see in the attached code, I am experimenting with WM_COPYDATA, but I am not sure if this is the right way.

Any reply will be greatly appreciated!

Thanks in advance, Perry

Apoch
November 17th, 2003, 10:06 AM
I don't have time to look at your hook code at the moment, but a quick suggestion is to try hooking WM_MOUSEMOVE or something instead. If you don't get any messages, double check that your hook code is proper, because you may be hooking the wrong thing. Also be sure you are setting a global hook (if you indeed want to hook other apps) or a local hook (if you just want to hook your own app).

As far as the second question, if you have an hWnd, you can get an hDC using the GetDC() API, and from there use BitBlt() to copy the image between device contexts. You may have to EnumChildWindows() if all you want is a single control on the target window, however.