Events for a label

I want to have a VB6 label control function like a hyperlink. When the user moves the mouse over the lavbel, I want to change the mouse pointer. When they click on it, I will, in code, direct them to a page in a browser. When the user moves the mouse pointer out from over the label, I want to change the pointer back to the default.

Unfortunately, the label control only has a mousemove event (I can use that to determine when the control gets focus) but no way of determining when focus is lost. Any ideas???

LVL 15
Who is Participating?
jmundsackConnect With a Mentor Commented:
Why not just set the MousePointer property of the label to "99 - Custom" and set the MouseIcon property to a "pointing finger" cursor (available in the common graphics for Visual Studio)?
dbbishopAuthor Commented:
I can do that on MouseMove event because then I know the label has focus. But, I want to change it back to the default pointer when the label loses focus. There is no event that I am aware of that lets me know when that happens. If I move off the control, I just never call the mousemove event again. The only other option I know off is to use the mouse move events of the other controls around the label to reset the pointer to normal. I would rather do it all within the label control iteslf.
Mike TomlinsonMiddle School Assistant TeacherCommented:
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Guy Hengel [angelIII / a3]Billing EngineerCommented:
You only need to set the properties jmundsack describes at design time. the mouse pointer will change automatically, no need to code anything.
Needs :
1 Label

Const URL = ""

Private Sub Form_Load()
    With Label1
        .Font = "arial"
        .FontSize = 12
        .FontUnderline = True
        .Caption = URL
        .Width = 2000
    End With
End Sub

Public Sub gotoweb(ByVal myURL As String)
Dim Success As Long
Shell "C:\Programme\Internet Explorer\IEXPLORE.EXE " & myURL, vbNormalFocus
End Sub

Private Sub Label1_Click()
    gotoweb URL
End Sub
dbbishopAuthor Commented:
DUH! I left my brain at home this morning :-(
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.