Re: Horizontal ScrollBar+ PictureBox + Flickering (how to stop flickering?)
- From: Frank Moyles <fgmoyles@xxxxxxxxxx>
- Date: Thu, 20 Dec 2007 21:27:56 +0000
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.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.
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
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?).
.
- Follow-Ups:
- Re: Horizontal ScrollBar+ PictureBox + Flickering (how to stop flickering?)
- From: Mike Williams
- 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
- Re: Horizontal ScrollBar+ PictureBox + Flickering (how to stop flickering?)
- From: Mike Williams
- Horizontal ScrollBar+ PictureBox + Flickering (how to stop flickering?)
- Prev by Date: Re: Can anyone tell me
- Next by Date: Re: Can anyone tell me
- 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
|