Animation in buttons

lukisf

Member
Joined
Apr 3, 2007
Messages
13
Programming Experience
1-3
Hi there,

First of all i'd like to thank those who helped me in my previous issues. I have a problem with animation (if you can call it animation). I'm new to GDI so i have no idea on how to do this. I'm working on a project and i'd like some form of animation. When the mouse is over a button, i'd like to change the colour of the button and to return to the original colour when the mouse leaves. However, i don't want this to change instantly. what i'm trying to say is this, I think if i add a timer control to the form and use it to fade the colour to the other one could work. But since i'm new to GDI, i don't know if this is possible. Any help please?

Thank you and Regards

Luke
 
I know this code is bad.

Hi,
I know the following code is not so good and expect a nicer solution from the experts in this community.

VB.NET:
Public Class Form1

    Private Sub Button1_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.MouseEnter
        Button1.BackColor = Color.FromArgb(0, 0, 255)
    End Sub

    Private Sub Button1_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.MouseLeave
        Dim g As Integer = 100

        While g < 255
            Button1.BackColor = Color.FromArgb(0, g, 255)
            Button1.Refresh()
            g += 1
        End While
    End Sub

End Class
 
Back
Top