Solved

Events for a label

Posted on 2006-11-01
6
781 Views
Last Modified: 2013-12-25
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???

Doug
0
Comment
Question by:dbbishop
6 Comments
 
LVL 13

Accepted Solution

by:
jmundsack earned 250 total points
ID: 17849603
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)?
0
 
LVL 15

Author Comment

by:dbbishop
ID: 17850353
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.
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 17850432
0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17850439
You only need to set the properties jmundsack describes at design time. the mouse pointer will change automatically, no need to code anything.
0
 
LVL 17

Expert Comment

by:vb_elmar
ID: 17850472
Needs :
=====
1 Label


Const URL = "whatismyip.com"

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
0
 
LVL 15

Author Comment

by:dbbishop
ID: 17850557
DUH! I left my brain at home this morning :-(
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

815 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now