Re: Horizontal ScrollBar+ PictureBox + Flickering (how to stop flickering?)





Mike Williams wrote:
"Frank Moyles" <fgmoyles@xxxxxxxxxx> wrote in message news:AYOdncoGruenIPfanZ2dnUVZ8vSdnZ2d@xxxxxxxxx

<snip></snip>
Presumably you are clearing the Picture Box (to remove any
trace of the previous graph) immediately before you draw the new graph into it? In that case then if you are drawing directly to the display there is a possibility (a certainty, actually) that sometimes the next actual hardware video frame will occur in between the time that you cleared the display (or even part way through the act of clearing the display) and before you have drawn the new graph on top of the cleared display. This will result in a blank display (a cleared area with no graph drawn into it), and more often a partially cleared area or a cleared area with a partially drawn new graph, being displayed at that specific video frame. This is the most common cause of flicker.

Drawing into a backbuffer eliminates (or at least partially eliminates) this specific cause of flicker because you clear the drawing area *in the invisible memory backbuffer* and you draw the new graph on top of the cleared area, again *in the invisible backbuffer*. You then transfer that complete drawing to the visible display from the backbuffer in one single blit. There is still a slight problem of course, because these "replace an old drawing with a new one" are not actually synchronised with the video display rate and so there will be occasions when more than one "complete new frame" is sent to the display hardware in a "single hardware frame period" and there may be times when less than one (none!) new frames are sent to the display hardware in a single "single hardware frame" period. If you want to take it further and if you want to also eliminate that specific cause of flicker (less of a problem than the first I've mentioned, but still a problem) then you need to clock your drawings to the actual video hardware frame rates, which usually means using DirectX. You can actually "clock frames using DirectX" in this way very easily in VB6 code, with very little extra code, but you will not of course ever get to the condition that you can achieve using raw DirectX (which I never get involved with myself and which I cannot therefore help you with).

Mike
Yes, you are definitely on the right track here (I dont think I want to get involved with DirectX though). From the way you describe the sequence of events, it seems that drawing into a buffer will eliminate most (if not all) of the flickering I'm experiencing.

Basically this is what I am doing. I have a C function DoPaintHwnd(), which accept a structure (contains an array of data points to plot) and the HWnd (or HDC) of the window/device to paint to. The first argument also specifies the start and stop points in the array (i.e. the 'window size' to be used to fetch the data to be plotted.

I am calling the DoPaintHwnd() function in the Paint Event of the picture box. I would appreciate a code snippet that shows how I may paint to a temporary buffer as you describe (do I use another [invisible] picture box and copy the painted picture over?).
.



Relevant Pages

  • Re: Horizontal ScrollBar+ PictureBox + Flickering (how to stop flickering?)
    ... to true has no effect - namely, 'scrolling the graph' still ... The reason the Autoredraw method works is because your entire "clearing and drawing code" runs in a closed loop for each specific "frame", and the VB Autoredraw method will not actually display the new frame until that "closed loop" code has finished. ...
    (microsoft.public.vb.general.discussion)
  • Re: double buffering
    ... >the middle of drawing a frame. ... If you're learning about double buffering, you might also want to look ... Once upon a time, not so long ago, we did not have frame ... whole and to display that whole. ...
    (comp.graphics.algorithms)
  • Re: howto avoid cdc drawing done not in onPaint to be erased?
    ... i need to draw something. ... And the answer is, if you want to do a drawing, then yes, you need to store every point ... A DC holds no display information; it holds the information required to CREATE the ... cases, for durations measuable in seconds, although small hundreds of milliseconds are ...
    (microsoft.public.vc.mfc)
  • Re: Display the length of a drawn line in Visio 2003?
    ... Common Visio Questions http://www.mvps.org/visio/common_questions.htm ... of the page where the XY coordinates now display) automatically as I ... drawing the line so I can tell when to stop. ... I've done some more fooling around and if I draw a rectangle, elipse, ...
    (microsoft.public.visio.general)
  • Re: Display the length of a drawn line in Visio 2003?
    ... a shape that does this (a line with a text field specifing length...grow the ... works if you draw or select the line first, ... What I would like is for the length to display at the logical place ... drawing the line so I can tell when to stop. ...
    (microsoft.public.visio.general)

Quantcast