Chat LIVE With Programming Experts! There Are 23 Online Right Now...

Welcome to Dream.In.Code
Become a VB.NET Expert!

Join 244,310 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 870 people online right now. Registration is fast and FREE... Join Now!




Working with animated button controls

 
Reply to this topicStart new topic

Working with animated button controls

tuxmeister
25 Nov, 2008 - 08:49 AM
Post #1

New D.I.C Head
*

Joined: 25 Jun, 2008
Posts: 36



Thanked: 2 times
My Contributions
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

User is offlineProfile CardPM
+Quote Post


magicmonkey
RE: Working With Animated Button Controls
25 Nov, 2008 - 10:10 AM
Post #2

D.I.C Regular
***

Joined: 12 Sep, 2008
Posts: 484



Thanked: 93 times
My Contributions
I don't see a handles clause at the end of the mousehover and mouseleave. Unless you added the handlers manually, that may be your problem.
User is offlineProfile CardPM
+Quote Post

tuxmeister
RE: Working With Animated Button Controls
25 Nov, 2008 - 02:31 PM
Post #3

New D.I.C Head
*

Joined: 25 Jun, 2008
Posts: 36



Thanked: 2 times
My Contributions
I just added the handles and still nothing. Maybe I should integrate the events in the control and then call them some how, but can't see how to do that.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 7/4/09 07:26PM

Live VB.NET Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month