Global Hook for Window Painting

L

Lunchtimemama

I am trying to modify another application's window (Google Talk) to
insert some UI of my own. I think the best method would be to install a
remote local hook in gtalk's thread that intercepts the paint message
and injects the custom UI. From the reading I've done, it is possible
to install a system hook with an unmanaged stub that passes execution
off to a managed C# delegate
(http://www.codeproject.com/csharp/GlobalSystemHook.asp), but some
types of hooks don't work, including WH_GETMESSAGE, which seems like
the hook I would use to intercept the paint message. So I need some
advice:

- Are the rules for remote local hooks different from those for system
hooks?
- Is WH_GETMESSAGE the right hook type?
- Is there in fact a way to install all types of system hooks with
managed code?
- Is the paint message the right thing to hook?
- Are hooks even the answer to this problem?

I am venturing into unknown territory and any assistance would be
greatly appreciated.
 
O

Ole Nielsby

Lunchtimemama said:
I am trying to modify another application's window (Google Talk)
to insert some UI of my own. I think the best method would be
to install a remote local hook in gtalk's thread that intercepts the
paint message and injects the custom UI.

I'm not an expert on interop but I know enough of win32 to
tell you this: WM_PAINT is not the thing to hook.

The handler for WM_PAINT goes something like:

DeviceContext graphics;
BeginPaint(out canvas);
PaintHeaven(canvas);
PaintFlyingPig(canvas);
// if you want spots on the pig, do it here
EndPaint(canvas);

There is no easy way to do that. When hooking, you will
have a go before or after the app's own handle, but the
canvas will not be available.

You should consider putting your UI stuff in a separate
window and put it on top of the app.

HTH/Ole N.
 
L

Lunchtimemama

Thanks for the advice. Q: What is the best way to monitor the target
window's creation/relocation/minimization/etc.?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top