|
-
Nov 19th, 2003, 11:55 AM
#1
Timer object anyone?
umm how do I work with it?
I'm declaring a new Timer object and adding a handle to its Elapsed event. Seems like my app hangs for some reason. Is there any dumb things that I can be doing wrnog?
I'm doing soemthing like this:
Dim t as new timer(2000)
....
t.start
addhandler t.elapsed, addressof blah
this is the whole thing in case you are interested to know. It's supposed to show the button two seconds after the mouse is hovered on the picturebox
VB Code:
Private t As New Timer(2000)
Private Sub PictureBox1_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox1.MouseEnter
t.Start()
End Sub
Private Sub PictureBox1_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox1.MouseLeave
t.Stop()
Button1.Visible = False
End Sub
Private Sub MouseHover2Seconds(ByVal sender As Object, ByVal e As ElapsedEventArgs)
Button1.Visible = True
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
AddHandler t.Elapsed, AddressOf MouseHover2Seconds
End Sub
very ingenious, right, hehe.
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Nov 19th, 2003, 11:59 AM
#2
Re: Timer object anyone?
Does the code currently work and you're only having the problem with it going slow or does it not work at all?
Originally posted by MrPolite
very ingenious, right, hehe.
annoying !=
ingenious
-
Nov 19th, 2003, 12:01 PM
#3
Re: Re: Timer object anyone?
Originally posted by kasracer
Does the code currently work and you're only having the problem with it going slow or does it not work at all?
annoying !=
ingenious
noo aint workin. app hangs and hangs then stops repainting hehe I'm acting like a compelete newbee now
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Nov 19th, 2003, 12:06 PM
#4
Why not just use the MouseHover event of the picturebox? Also I thought it was the Tick event you use.
VB Code:
Private Sub PictureBox1_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox1.MouseHover
Button1.Visible = True
End Sub
Private Sub PictureBox1_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox1.MouseLeave
'although unless the button is in the picturebox they wont eb able to click it
'since it will disappear when they leave the picturebox to click it
Button1.Visible = False
End Sub
-
Nov 19th, 2003, 12:11 PM
#5
-
Nov 19th, 2003, 12:24 PM
#6
Originally posted by MrPolite
umm well! I wanted the button to appear AFTER a delay. Kinda like in IE when you hover over a picture, after a lil while it will show the save/print/bleh buttons I havent used timers so I'm gussing I'm doing something really wrong
Well that is what the MouseHover event does, but if you want more control over the time it takes or really want to use the Timer then:
VB Code:
Private WithEvents _Timer As New Timer
Private Sub PictureBox1_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox1.MouseLeave
'although unless the button is in the picturebox they wont eb able to click it
'since it will disappear when they leave the picturebox to click it
Button1.Visible = False
_Timer.Enabled = False
End Sub
Private Sub PictureBox1_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox1.MouseEnter
_Timer.Interval = 2000
_Timer.Enabled = True
End Sub
Private Sub _Timer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles _Timer.Tick
Button1.Visible = True
End Sub
There is more than one Timer object so check which one you are using. I am using the one from the Windows.Forms namespace not the Threading namespace one.
-
Nov 19th, 2003, 12:35 PM
#7
Originally posted by Edneeis
Well that is what the MouseHover event does, but if you want more control over the time it takes or really want to use the Timer then:
VB Code:
Private WithEvents _Timer As New Timer
Private Sub PictureBox1_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox1.MouseLeave
'although unless the button is in the picturebox they wont eb able to click it
'since it will disappear when they leave the picturebox to click it
Button1.Visible = False
_Timer.Enabled = False
End Sub
Private Sub PictureBox1_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox1.MouseEnter
_Timer.Interval = 2000
_Timer.Enabled = True
End Sub
Private Sub _Timer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles _Timer.Tick
Button1.Visible = True
End Sub
There is more than one Timer object so check which one you are using. I am using the one from the Windows.Forms namespace not the Threading namespace one.
hmm that one works? I was using teh one from System.Timers
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|