VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Create links from labels

by Paul Spiteri (3 Submissions)
Category: Internet/HTML
Compatability: Visual Basic 3.0
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (5 Votes)

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

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

Rate Create links from labels

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

Download this snippet    Add to My Saved Code

Create links from labels Comments

No comments have been posted about Create links from labels. Why not be the first to post a comment about Create links from labels.

Post your comment

Subject:
Message:
0/1000 characters