[quoted text, click to view] >Hi,
>I need something which could work continusly. I need to show the pixel
>color
>under the mouse while it moves, then when clicked I need to get the
>color. How can I do this in an appropriate way ?
I am not quite sure what you mean. Either of
1) You want something like what a screen magnifier does, i.e. inspect
what is under the mouse, but not actually interferring with normal
mouse operations. In this case, even though you are just moving
the mouse, other applications might change appearance, e.g. when
moving the mouse over a toolbar icon. Your application has no way
of detecting that you clicked the mouse button, so you would have
to use a hotkey or similar to tell the application that you want to
grab something now.
In this case, just grab the screen (pixel) at the time the hotkey
is invoked.
2) Like 1), but instead of using a hotkey, you can capture the mouse
until the mouse button has been clicked. In this case, other
applications will not be affected by moving the mouse over them,
but the user needs to initiate the "I want to grab a color now"
sequence somehow (e.g. by clicking a button or by invoking
the inspection window).
3) Your application maintains control of the mouse and you do not
want any applications to change their appearance while you move
the mouse over them. In this case you could grab the entire
desktop, then overlay the desktop with a full-screen form
containing this screen grab. Put your inspection window
on top of this full-screen form. When the mouse button is clicked,
remove the full-screen overlay.
Like 2), this requires initiation by the user.
4) Rather than faking it like in 3), you could simply grab a copy of
the desktop, but instead of displaying it in an overlay (giving
the illusion that the desktop is still visible), just put it in a
scollable window and let the user inspect the pixels in that
window. Although this might require that the user resizes
and/or scrolls this window, it is much more obvious what is
going on.
At any rate, providing some kind of zooming functionality is
normally beneficial, in which case this would be the best
solution, but I do not know what your application is supposed
to do.
BTW: I tried an old (non-.Net) magnifier application (Zoom+) on Vista
with
Aero enabled, and it did not seem to have any problems querying
the screen multiple times a second. Perhaps there is no problem after
all? At any rate, whatever you do, if you use the desktop device
context, test it on Vista with Aero enabled. Just in case. I'm not
sure.
/JB