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



"Steve Gerrard" <mynamehere@xxxxxxxxxxx> wrote in message news:S6KdnQoNi-jatvbanZ2dnUVZ_g6dnZ2d@xxxxxxxxxxxxxx

Is there a way OP could BitBlt most of the existing graph to
the left or right, and then draw in the new section? This seems
to be a common method in MS Word and such for updating
the display without redrawing everything.

Yes, there is. Thanks for pointing that out. When the user moves the scroll bar you just need to compare the start and end points of the "already drawn" data and compare it to the new required start and end points and blit the appropriate "already drawn" part into its new position and then clear the rest of the graph and draw the new data points. The total amount of blitting is the same of course, because with either method you need to blit the full width of the graph, but the number of lines you need to draw is less because you are drawing only the newly required lines. Personally when drawing graphs consiting of single pixel thickness lines I usually I opt for the simplicity of clearing the entire graph and drawing the entire new set of data on the grounds that drawing single pixel thickness lines (especially if you use PolyLine) is usually very fast. Your suggested method is definitely the way I would do it though if the lines were greater than a single pixel thick (because drawing such lines is much slower) or if the graph contained various filled areas or other more complex elements. That's why things like Microsoft Word use such a method, because the stuff that is drawn to the page is often quite complex and in such cases it is very much faster to use the method you have suggested. In both cases of course you really need to be composing the drawing into a backbuffer and then transferring the completed drawing to the display in one go, to avoid flicker. Naturally in some cases (where the entire graph is not too large and is reasonably static) you can even use the very simple method of drawing the entire graph into memory and simple display the appropriate part of it using a single blit. There are all sorts of different methods.

Mike



.



Relevant Pages

  • Re: Which component to use to display mathematical graphs with VB6
    ... Your code can then draw into that Form's client area (the area ... inside its borders) or alternatively into a PictureBox that you can ... generally very fast at drawing a set of many lines in one call using a ... Do you mean you want your graph to cover all of the available screen ...
    (comp.lang.basic.visual.misc)
  • Re: Polyline slow
    ... when I try to draw the graph with polyline I see the slowdown. ... I can't feel anything related drawing ...
    (microsoft.public.vc.language)
  • Re: Hey, Jobst, on p39 of The Bicycle Wheel the graph appears to show the ?impossibility of...
    ... that is actually a graph of. ... Actually I did say I would draw the diagram differently in the sense ... After numerous posts apparently criticising the drawing, ...
    (rec.bicycles.tech)
  • Selecting Graph Colours
    ... I'm drawing a graph in a picture box, and would like to draw each line in a ...
    (microsoft.public.vb.general.discussion)
  • Re: Drawing on DC
    ... class Circle: public Drawing { ... It would be *called* from OnDraw, ... You should only draw when you need to draw, ... Drawing your objects on a bitmap merely renders the circle, rectangle, etc. as bits (which ...
    (microsoft.public.vc.mfc)

Quantcast