Results 1 to 4 of 4

Thread: Putting a Hyper-Link on a Form? (lost the thread)

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2000
    Posts
    84
    Ack - I asked this question yesterday, and before I read the answer the thread had scrolled off the last page!

    I wanted to know how to add a Hyperlink to a form....

    (a clickable link to say "VB-World.Net"

    Thanks!

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Assuming there is a form with a lblURL label on it

    Code:
    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, .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
    Also make sure you change the lblURL.DragIcon to something else it looks really dumb. ALso in this case it assumes that the URL is in the caption of the label.

  3. #3
    Guest
    You forgot to include the ShellExecute API function .

    Code:
    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
    
    Public Const SW_SHOWNORMAL = 1
    
    Usage
    
    ShellExecute Me.hwnd, vbNullString, "http://www.vb-world.net", _
    vbNullString, "c:\", SW_SHOWNORMAL

  4. #4
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Code:
    'uses Form1,Image1,Label1
    'change the mouse cursor to whatever image you
    'for this example I use the hand
    'send user to web address on click event of label
    
    Option Explicit
    
    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 Const SW_SHOWNORMAL = 1
    
    Private Sub Form_Load()
    Image1.Picture = LoadPicture("C:\Windows\Cursors\Hand-m.cur")
    Image1.Visible = False
    End Sub
    
    Private Sub Form_MouseMove(Button As Integer, _
        Shift As Integer, X As Single, Y As Single)
        Me.MousePointer = vbDefault
    End Sub
    
    Private Sub Label1_Click()
        Dim lReturn As Long
        lReturn = ShellExecute(hWnd, "open", _
                   "http://www10.ewebcity.com/dirtbagdog/", _
                     vbNull, vbNull, SW_SHOWNORMAL)
    
    End Sub
    
    Private Sub Label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        Me.MousePointer = 99
        Me.MouseIcon = Image1.Picture
    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width