Controlling flicker in mouse move events

Controlling flicker in mouse move events

Post by John Colem » Fri, 07 Oct 2005 00:17:55

In a class I am currently teaching we are about to talk about
gradient vectors. I prepared an XY scatter-chart whose background was
set to be a contour-map of a function of 2 variables. I wrote a
mouse-move event handler which draws the gradient to the surface at
that point. After I was finally able to find a way to translate from
the annoying "client coordinates" returned by the mouse move event into
the coordinate system determined by the chart axis, I was able to get
it to work as I intended. The problem is - flicker! Big time. I've
tried things like briefly turning off screen updating, etc. But nothing
seems to work. From this group I downloaded a function to wrap an API
call to LockWindows (or something like that), but it didn't seem much
better than toggling screen-updating. In frustration, I turned it into
a mouse-down event. I can still move around the contour, clicking here
and there to display the gradient, but it now lacks the animation which
would be have been cool. Is there a work around or is this just an
unavoidable by-product of the fact that Excel wasn't designed for

Thanks in advance

-John Coleman

Controlling flicker in mouse move events

Post by R3JlZyBXaW » Fri, 07 Oct 2005 11:25:08


I suggest, instead of using mouse_move, to make the code a standard macro
and assign the macro to a keyboard key by means of Application.OnKey. When
you hold down the key it should repeatedly execute the macro. Based on very
limited experience, it is smoother than mouse-move and obviously has the
advantage of easily being turned-off (let go the key).

Note that I only suspect it will work. I have no experience other than with
a much simpler scenario. Interested in the outcome pro or con.