Results 1 to 6 of 6

Thread: Making label into web link

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2000
    Location
    UK
    Posts
    66

    Post

    Hi,

    I want to make a label on a form (in VB5) to be a web link when it's clicked on.

    It works great - I've down the ShellExecute bit and and set the mouseicon property to display the link select cursor, but what I want is the label to change colour when the mouse passes over it!

    Sounds simple but I can't do it

    Hope someone can help me

    Simon

  2. #2
    Frenzied Member Buzby's Avatar
    Join Date
    Jan 1999
    Location
    UK
    Posts
    1,670

    Post

    In the MouseMove event of the label;

    Label1.ForeColor=vbBlue

    In the MouseMove event of the form (or the fram if the label is inside a frame)

    Label1.ForeColor=vbBlack



    ------------------
    Mark "Buzby" Beeton
    VB Developer
    [email protected]



  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jan 2000
    Location
    UK
    Posts
    66

    Post

    Is this really the best way? It doesn't always change back to blue straigh away when it moves off the label back onto the form.

    Simon

  4. #4
    Hyperactive Member
    Join Date
    Feb 2000
    Location
    the UK
    Posts
    265

    Post

    That's the right code for launching the web browser but doesn't change the colours!

    Simon

  5. #5
    Hyperactive Member
    Join Date
    Feb 2000
    Location
    the UK
    Posts
    265

    Post

    My greatest apologies Buzby - the label was in a frame and I didn't do that bit properly!

    Thanks for the answers folks.

    Simon

  6. #6
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238

    Post

    You can add the following code into your label1 click events module:

    Public Sub Label1_Click()
    Dim Success As Long
    Dim URL = "http://www.vb-world.net"

    Success = ShellExecute(0&, vbNullString, URL, vbNullString, "C:\", SW_SHOWNORMAL)

    End Sub

    BTW, byou need to declare the following API function:

    Public 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

    [This message has been edited by Chris (edited 02-10-2000).]

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