By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,422 Members | 1,310 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,422 IT Pros & Developers. It's quick & easy.

Global Hook for Window Painting

P: n/a
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.

May 28 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Lunchtimemama <lu***********@gmail.com> wrote:
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.

May 29 '06 #2

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

May 30 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.