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





Mike Williams wrote:

"Frank Moyles" <fgmoyles@xxxxxxxxxx> wrote in message news:wMydncOyocwrHvfaRVnyhAA@xxxxxxxxx

I have a PictureBox placed on a form, as well as a horizontal
scroll bar. I am drawing a graph (output from an instrument)
on the PictureBox. I am 'scrolling' the graph by dragging the
horizontal scroll bar. Each time the scroll bar changes, I am
getting the new values and using that event to redraw the
graph - it works in theory, but in practise, it flickers quite a lot.


Try drawing into a backbuffer first. One very easy way of doing this is to simply set the Autoredraw property of the PictureBox to True, which will eliminate the flicker. You might also like to try speeding up the drawing of your graph lines using the PolyLine API instead of drawing the individual lines one by one (if that is what you are currently doing).

Mike



Hi Mike, setting AutoRedraw property of the PictureBox to true has no effect - namely, 'scrolling the graph' still causes flickering.

Additionally, I am using third party graphics library so I cannot use teh PolyLine API as an alternative. Hmmm, this seems to leave me with only one alternative (drawing into a buffer).

On the face of it - I can't se how it will work, since I am repainting the graph on every scroll( for fine garnualrity) and change (coarser granularity) event - so I'm not sure how drawing to a back buffer might help - unless I'm missing something - e.g. draw a graph with a bigger window size and then 'slide' that window accross - even using this technique, there are likely to be times (at the edge of the 'window') when the graph may flicker as a new 'window is loaded - is this the approach you had in mind ?
.



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: Horizontal ScrollBar+ PictureBox + Flickering (how to stop flickering?)
    ... I am drawing a graph ... horizontal scroll bar. ... Try drawing into a backbuffer first. ... One very easy way of doing this is to simply set the Autoredraw property of the PictureBox to True, ...
    (microsoft.public.vb.general.discussion)
  • Redrawing a part of a control
    ... I am drawing some lines on a picturebox control. ... graph based on some changing variables in memory. ... Invalidate method of the picturebox to redraw the lines. ...
    (microsoft.public.dotnet.languages.vb)
  • Horizontal ScrollBar+ PictureBox + Flickering (how to stop flickering?)
    ... I have a PictureBox placed on a form, as well as a horizontal scroll bar. ... I am drawing a graph on the PictureBox. ...
    (microsoft.public.vb.general.discussion)
  • Re: Horizontal ScrollBar+ PictureBox + Flickering (how to stop flickering?)
    ... 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 is usually very fast. ...
    (microsoft.public.vb.general.discussion)

Loading