Hey guys!
I am trying to build an animated button control (.dll). This control contains an imagelist which will hold the "frames" of the animation (different states of the button), two timers; one for the "slide out" event and the other for the "slide in" event, which will return the button to it's normal state, and also an imagebox which will hold the different frames of the animated button. The button control contains the code for all those 4 elements.
CODE
Public Class test_button
Dim imageNumber As Integer = 0
Private Sub test_button_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Button1.Image = frame_holder.Images(0)
End Sub
Private Sub Slide_out_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Slide_out.Tick
If imageNumber = frame_holder.Images.Count - 1 Then
Slide_out.Stop()
Else
imageNumber = imageNumber + 1
Button1.Image = frame_holder.Images(imageNumber)
End If
End Sub
Private Sub Slide_in_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Slide_in.Tick
If imageNumber = frame_holder.Images.Count - 8 Then
Slide_in.Stop()
Else
imageNumber = imageNumber - 1
Button1.Image = frame_holder.Images(imageNumber)
End If
End Sub
End Class
I built and added this custom control to the form, and created two events for it: MouseHover, which will trigger the "Slide_out" timer, and a MouseLeave event, which triggers the "Slide_in" event.
CODE
Public Class test
Private Sub Test_button1_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs)
Test_button1.Slide_out.Start()
End Sub
Private Sub Test_button1_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs)
Test_button1.Slide_in.Start()
End Sub
End Class
The problem I have is when I launch the application: the events do not trigger the timers contained in the control, therefore nothing happens to the button. Any idea of why this is happening, and if so, any of correcting it?
I chose this way of doing it so I do not clutter the main form with code and extra events for the timers, and also to be able to further dispose separate controls and also the code that rule them, so I can manage the performance of the application.
NOTE: this is not a class assignment nor work-related, I am only playing with this for fun and the application will have personal use.
Any help will be much appreciated.
Many thanks,
TuxMeister
This post has been edited by tuxmeister: 25 Nov, 2008 - 08:54 AM