Hooking mouse event - question of performances
am 04.11.2007 11:02:14 von Tom Rahav
Hello,
I try to develop application that runs in the background and suppose to
display a small form with menu whenever the user clicks the middle mouse
button (also when my application is not the active one).
I have found a nice way to do it with hooking mouse events and reactring
accordingly. but I'm affriad that this method is a performances killer for
the OS.
Is there a better way to do it? How "killer" is my way anyway?
Thanks!
Tom.
Re: Hooking mouse event - question of performances
am 04.11.2007 19:36:44 von Andrew Faust
If you need a global event then a windows Hook is the way to do it. The
performance impact will be based solely on what you are doing. It's
possible to write the handler so that it doesn't impact performance.
A few things to note. You should provide your users the ability to disable
this hook easily. Some of us are already running custom mouse drivers that
let us override mouse clicks. Don't assume that we always want to use your
functionality instead of what we have set up. There may be other cases
where your functionality could screw us up. For example if the user is in a
game, having your form pop up because they accidentally clicked a button
could crash the game. Finally, I've never built a hook in .Net, so can't
comment on the performance in a managed language. However, I do know that
in C++ at least I've built hooks that had no noticable impact on
performance.
--
Andrew Faust
andrew[at]andrewfaust.com
http://www.andrewfaust.com
"Tom Rahav" wrote in message
news:%23APO5nsHIHA.5328@TK2MSFTNGP05.phx.gbl...
> Hello,
> I try to develop application that runs in the background and suppose to
> display a small form with menu whenever the user clicks the middle mouse
> button (also when my application is not the active one).
> I have found a nice way to do it with hooking mouse events and reactring
> accordingly. but I'm affriad that this method is a performances killer
> for the OS.
> Is there a better way to do it? How "killer" is my way anyway?
>
> Thanks!
> Tom.
>