Re: Horizontal ScrollBar+ PictureBox + Flickering (how to stop flickering?)
- From: "Mike Williams" <mikea@xxxxxxxxxxxxxxxxx>
- Date: Thu, 20 Dec 2007 20:48:33 -0000
"Frank Moyles" <fgmoyles@xxxxxxxxxx> wrote in message news:AYOdncoGruenIPfanZ2dnUVZ8vSdnZ2d@xxxxxxxxx
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 the PolyLine API as
an alternative.
Well that third party graphics library is quite likely the problem. The reason the Autoredraw method works (or at least works as well as can be expected) 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.
Hmmm, this seems to leave me with only one alternative
(drawing into a buffer).
Well that's what Autoredraw does, although there are of course other ways of doing it.
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.
Yes. You are missing something. A lot depends on what you mean by "flicker". 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
.
- Follow-Ups:
- Re: Horizontal ScrollBar+ PictureBox + Flickering (how to stop flickering?)
- From: Frank Moyles
- Re: Horizontal ScrollBar+ PictureBox + Flickering (how to stop flickering?)
- References:
- Horizontal ScrollBar+ PictureBox + Flickering (how to stop flickering?)
- From: Frank Moyles
- Re: Horizontal ScrollBar+ PictureBox + Flickering (how to stop flickering?)
- From: Mike Williams
- Re: Horizontal ScrollBar+ PictureBox + Flickering (how to stop flickering?)
- From: Frank Moyles
- Horizontal ScrollBar+ PictureBox + Flickering (how to stop flickering?)
- Prev by Date: Re: Setting VB IDE to MDI permanently
- Next by Date: Re: Horizontal ScrollBar+ PictureBox + Flickering (how to stop flickering?)
- Previous by thread: Re: Horizontal ScrollBar+ PictureBox + Flickering (how to stop flickering?)
- Next by thread: Re: Horizontal ScrollBar+ PictureBox + Flickering (how to stop flickering?)
- Index(es):
Relevant Pages
|