CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: url in form

  1. #1
    Join Date
    Jul 1999
    Location
    Norway
    Posts
    32

    url in form

    How can I add an url like www.microsoft.com into my form, and make the browser start when the user press mouse-button on the url (like a url on the web...)

    thanks...


  2. #2
    Join Date
    May 2001
    Location
    Russia
    Posts
    200

    Re: url in form


    private Sub Label1_Click()
    Shell "C:\Program Files\Internet Explorer\IEXPLORE.EXE http://www.microsoft.com", vbMaximizedFocus
    End Sub




    In Label1.Caption print http://www.microsoft.com

    Andy Tower

  3. #3
    Join Date
    Mar 1999
    Location
    Nepal
    Posts
    540

    Re: url in form

    You use a label as Tower suggested with the caption set to the URL you want to launch. Then use the following code.

    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_SHOW = 5

    private Sub Label1_Click()
    ShellExecute frmMailTo.hwnd, "open", label1.caption, vbNullString, vbNullString, SW_SHOW
    Unload me
    End Sub




    This will launch the default browser, and you don't need to know the full path of the browser executable.

    Optionally, you can set the label's MousePointer property to the Hand icon.

    If you want to give a hyperlink like effect, you can set the forecolor of the label to blue. In Label_MouseMove, set the forecolor to red. In the MouseMove event of the Form, reset the label's forecolor back to blue.


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

Featured