Initial Black Flicker on Fade

G

Guest

Greetings

Having a problem with a little flicker that is annoying. On the close of the form, would like to fade it out. I use a timer and decrease the opacity as it ticks. Here's the deal, with a small form with few controls, the flicker is not too bad and could be tolerable. Now, when you have a lot of controls on the form it gets really bad.

Here's a better description of what happens: when the "fade button (this case the OK button), the form area is painted completely black, then it paints the original form, with the lesser opacity, then keeps incrementing down. It only happens upon starting the fade feature. For some forms, usually large, it seems like the form is rolling into the center to create the initial black outline, then normal fading, although this may be an optical illusion.

Any ideas would be appreciated.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Clic
timerFade.Enabled = Tru
End Su

Private Sub timerFade_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles timerFade.Tic
If Me.Opacity <= 0 The
Me.Close(
Els
Me.Opacity = Me.Opacity - 0.0
End I
End Sub
 
M

Mitch Ruebush

The timer you are using is the System.Windows.Forms.Timer. This will have
issues when you have a large UI because application code will never be
preempted by the timer. I believe that you will need to use a
System.Timers.Timer to make this work right. See msdn article:
http://msdn.microsoft.com/msdnmag/issues/04/02/TimersinNET/default.aspx

Mitch Ruebush
Microsoft Regional Director -
http://www.microsoftregionaldirectors.com
Visual Developer - .NET MVP -
Architect | Evangelist | Teacher
Online Consulting, Inc. - http://www.onlc.com
MCSD, MCAD, MCDBA, MCSE, MCT

Greetings,

Having a problem with a little flicker that is annoying. On the close of
the form, would like to fade it out. I use a timer and decrease the opacity
as it ticks. Here's the deal, with a small form with few controls, the
flicker is not too bad and could be tolerable. Now, when you have a lot of
controls on the form it gets really bad.
Here's a better description of what happens: when the "fade button (this
case the OK button), the form area is painted completely black, then it
paints the original form, with the lesser opacity, then keeps incrementing
down. It only happens upon starting the fade feature. For some forms,
usually large, it seems like the form is rolling into the center to create
the initial black outline, then normal fading, although this may be an
optical illusion.
Any ideas would be appreciated.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
timerFade.Enabled = True
End Sub

Private Sub timerFade_Tick(ByVal sender As Object, ByVal e As
System.EventArgs) Handles timerFade.Tick
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top