Click here to Skip to main content
15,917,862 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have created a moving label with this code:
VB
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    MovingNameLabel.SetBounds(MovingNameLabel.Location.X - 1, 1, 223, 45)
    If MovingNameLabel.Location.X <= -339 Then
        MovingNameLabel.Location = New Point(461, MovingNameLabel.Location.Y)
    End If
End Sub

The problem I am facing is that while the label is moving, the end of it flashes. I do have it set to transparent, so does that have any affect? Any suggestions would be greatly appreciated! :)
Posted
Comments
Sergey Alexandrovich Kryukov 15-Aug-11 0:18am    
Tag it! WPF, Forms, APS.NET, what?!
--SA
NY Andrew 15-Aug-11 0:19am    
?.. It does say VB10, and VB.net... And it is on a form.
Sergey Alexandrovich Kryukov 15-Aug-11 0:19am    
By the way, it looks like you're using pretty bad thing -- System.Windows.Forms.Timer (or don't you?) If so, don't expect smooth motion.
--SA
NY Andrew 15-Aug-11 0:20am    
Whats a good suggestion instead of using the timer? I am not going to use that stupid sleep function..

1 solution

Try setting the Form DoubleBuffered[^] property to True - that may cure the flickering.
 
Share this answer
 
Comments
NY Andrew 15-Aug-11 3:41am    
You know what's funny, I looked into that but I did not understand any of it, but anyway THANK YOU SOO MUCH!!! It worked PERFECTLY without the flash and it even looks smoother! Thank you so much! May I ask what this DubbleBuffer property actually does?
OriginalGriff 15-Aug-11 3:58am    
When the from is drawn, instead of being drawn directly onto the screen, it is drawn into a separate buffer, which is then transferred to the screen. Because the background erase (which is the first thing done for a re-paint) is done to the buffer, not the screen, the objects on your form don't disappear first and then get redrawn.
It works, but it takes additional processing time as the buffer has to be copied to the display memory when painting is complete.
NY Andrew 15-Aug-11 4:02am    
Oh! Ok! That makes sense. Thanks for the great explanation. I tried reading Microsofts but I couldn't make out anything it was saying. So my last question would be, when the form has successfully loaded will it be using any additional RAM? or once the buffer has completed it erases the copied buffer?
OriginalGriff 15-Aug-11 5:35am    
Don't worry about it: it is deleted when it finishes with it, but even if your app fills the desktop at 1680x1050, that would still only be 7Mb anyway! :laugh: You probably allocate more than that already...
NY Andrew 15-Aug-11 14:32pm    
Alright, good to know. And yea haha, I'm way over that already! Well once again thanks for all your help! :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900