autoscrollposition and invalidate()

J

Jon

I am writing a graphics application that
supports "zooming". I have implemented some code that
forces the zoom to occur around the center of the client
window. So, the code recalculates the PageScale, which
will be changed when the Paint event is called, then
calculates the offset required to return the original
center coordinate to the center of the client window after
the zooming has occurred.

However, when I use the AutoScrollPosition to set the
offset distance, the program is repainting only part of
the client window. The last command of the method calls
the Invalidate() method, which corrects the screenshot.
However, the brief incorrect repainting is causing
a "flicker".

Any suggestions?
 
G

Greg Ewing [MVP]

Jon, how are you displaying the image? One way to eliminate flicker is to
follow these steps:

1. Draw your image using the image class in memory.
2. Display that image using an image control or other means
3. make any changes to your image in memory, zooming etc...
4. Change the visible image to the new image.

By not displaying the image which you are working on you can eliminate most
flicker. Hope that helps.
 
J

Jon

Greg,

The application is drawing the image directly to the
graphics object provided by the paint method. I figured
the answer was going to revolve around manual "buffering",
but it is a little complicated since I have several
routines that handle different aspects of drawing.

I will give it a shot with a manual buffering technique
such as the one you suggested. Theoretically, I should be
able to turn off the automatic double buffering I had
previously enabled, since I am now going to handle this
manually, correct?

Thanks for your help.

Jon
 
G

Greg Ewing [MVP]

Jon, yes, in theory you should be able to turn that off. You might find
though that it makes the graphics changes just a little neater and cleaner.
 
J

Jon H.

Greg,

The basis of the problem seems to be that because I am
adjusting the autoscrollposition, buffering will not be
able to control the graphic. The code is automatically
invalidating only the part of the screen that was not
displayed before the scroll adjustment was performed.
This is what is causing the "flicker".

What I need is a more detailed control of the scrollbar
behavior. Specifically, I need the Invalidated rectangle
upon scrolling to be the entire clientrectangle and I need
to suspend any redrawing of the scrollbars themselves
until my code has programmatically made the necessary
adjustments to the scrollbar positions. Any suggestions?

Thanks in advance.
 
G

Greg Ewing [MVP]

Jon, any chance you could post some code which demonstrates the problem you
are running in to? A complete, runnable, program would be great.
 

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