Search Tools Links Login

Create links from labels!


Turns labels into links which when clicked, load the contents of the caption as the URL into a webbrowser.

Original Author: Paul Spiteri

Inputs

Private Sub Form_Load()
MakeLink Label1, Startup
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
MakeLink Label1, FormMove
End Sub
Private Sub Label1_Click()
MakeLink Label1, Click, Me
End Sub
Private Sub Label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
MakeLink Label1, LinkMove
End Sub

API Declarations

Public Enum OpType
Startup = 1
Click = 2
FormMove = 3
LinkMove = 4
End Enum
Dim Clicked As Boolean
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

Code

Public Sub MakeLink(LabelName As Label, Operation As OpType, Optional FormName As Form)
  Dim Openpage As Integer
  
  Select Case Operation
  Case LinkMove
    LabelName.ForeColor = 255
    LabelName.FontUnderline = True
  Case Click
    Openpage = ShellExecute(FormName.hwnd, "Open", LabelName.Caption, "", App.Path, 1)
    LabelName.ForeColor = 8388736
    Clicked = True
  Case FormMove
    LabelName.FontUnderline = False
    If Not Clicked Then
      LabelName.ForeColor = 16711680
    Else
      LabelName.ForeColor = 8388736
    End If
  Case Startup
    LabelName.ForeColor = 16711680
  End Select
End Sub

About this post

Posted: 2002-06-01
By: ArchiveBot
Viewed: 71 times

Categories

Visual Basic 6

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.