Most programs now include a hyperlink in their about box linking to their web site or product support email. That is simple enough, but some also include a 'rollover' effect, which is not quite so easy in VB. Fortunately, you can hack around this limitation by convincing VB that you are actually dragging something over the hyperlink... Then VB will give you the DragOver information you need. Below is some example source code. Create a label, and name it lblURL, and set its caption property to the internet address you want. If the URL is an email address, then un-comment the line in green, and comment out the line below that.
Private Declare Function ShellExecute Lib "shell32.dll" Alias
"ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile
As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As
Long) As Long
Private Sub lblURL_DragDrop(Source As Control, X As
Single, Y As Single)
If Source Is lblUrl Then
With lblUrl
.Font.Underline
= False
.ForeColor =
vbBlack
'
Call ShellExecute(0&, vbNullString, "Mailto:" & .Caption,
vbNullString, vbNullString, vbNormalFocus)
Call
ShellExecute(0&, vbNullString, .Caption, vbNullString, vbNullString,
vbNormalFocus)
End With
End If
End Sub
Private Sub lblURL_DragOver(Source As Control, X As Single, Y As Single, State
As Integer)
If State = vbLeave Then
With lblUrl
.Drag
vbEndDrag
.Font.Underline
= False
.ForeColor =
vbBlack
End With
End If
End Sub
Private Sub lblURL_MouseMove(Button As Integer, Shift As Integer, X As Single, Y
As Single)
With lblUrl
.ForeColor = vbBlue
.Font.Underline = True
.Drag vbBeginDrag
End With
End Sub
Comments