flicker

  • Thread starter Thread starter steve
  • Start date Start date
S

steve

ok, ok...obj.suspendlayout/resumelayout. but it isn't helping and i need
advice. i have a custom progress bar made from a label control. i manually
paint it when the progress changes. i'm drawing a filled, rounded rectangle
twice w/n the label...once to give a light background color, the second time
is the show the progress. the third paint operation is to draw the progress
info text w/n the label. everything works just fine, but when progress
changes rapidly, i get flickering of all text and color layers...even though
i'm suspending layout ops prior to the graphics changes, then resuming.

any ideas on a quick fix...or anyone know how i can apply these graphics
operations to the label all at once?

tia,

steve
 
Step right up young man! You're in the market for a second Graphics object!
What you are doing is animation and animation needs two Graphics objects to
remove that flicker effect. The flicker effect is happening because you are
updating the on-screen graphics object where your eye can see the changes.
Instead, create a second graphics object (an off-screen one), draw the new
image there and then copy it to the on-screen object. If using DirectX,
they even supply routines to time the swap with the vertical refresh which
makes things even better.
 
Steve,
Why a label? I would start with Control or UserControl...

In your user control's constructor you should use the following:
' Stop the flicker
Me.SetStyle(ControlStyles.UserPaint, True)
Me.SetStyle(ControlStyles.DoubleBuffer, True)
Me.SetStyle(ControlStyles.AllPaintingInWmPaint, True)
Me.SetStyle(ControlStyles.ResizeRedraw, True)
Me.UpdateStyles()

The ControlStyles.DoubleBuffer is .NET's method of having a second Graphics
object as Tyson was suggesting. The other settings help out, see online help
for specifics on each ControlStyle.

After you include the above in your constructor, you only need to handle the
Paint event and paint your control's surface.

Hope this helps
Jay
 
Jay B. Harlow said:
In your user control's constructor you should use the following:
' Stop the flicker
Me.SetStyle(ControlStyles.UserPaint, True)
Me.SetStyle(ControlStyles.DoubleBuffer, True)
Me.SetStyle(ControlStyles.AllPaintingInWmPaint, True)
Me.SetStyle(ControlStyles.ResizeRedraw, True)
Me.UpdateStyles()

Golly, looks like I've been working at too low a level. That doublebuffer
thingy sounds neato! I was doing that sort of work myself! I hate it when
languages get so clever but fail to tell me how they can make my coding
simpler!
 
thanks to you both. works perfectly now. i apparently have also fallen into
the "get so clever/low level" trap.

thanks again,

steve


|
| | > In your user control's constructor you should use the following:
| > ' Stop the flicker
| > Me.SetStyle(ControlStyles.UserPaint, True)
| > Me.SetStyle(ControlStyles.DoubleBuffer, True)
| > Me.SetStyle(ControlStyles.AllPaintingInWmPaint, True)
| > Me.SetStyle(ControlStyles.ResizeRedraw, True)
| > Me.UpdateStyles()
|
| Golly, looks like I've been working at too low a level. That doublebuffer
| thingy sounds neato! I was doing that sort of work myself! I hate it
when
| languages get so clever but fail to tell me how they can make my coding
| simpler!
|
 
Back
Top