Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

vb linking images with websites

  • 04-02-2003 3:37pm
    #1
    Closed Accounts Posts: 1,152 ✭✭✭


    hey everyone..just checked the net and looked through my vb book here at college and found nothing on this subject so..just wondering is there any way to link an image to a website in its click event?
    thanks


Comments

  • Registered Users, Registered Users 2 Posts: 2,591 ✭✭✭tommycahir


    did you try using the ole component
    the msdn lib also prob have some code on it


  • Closed Accounts Posts: 1,152 ✭✭✭sound_wave


    ok thanks..see we havent gotten that far yet in our lectures so ill be going out on a limb here..trying to impress the lecturer for my project
    thanks


  • Closed Accounts Posts: 9,314 ✭✭✭Talliesin


    Not entirely sure I know what you want to do, but I'm guessing you want code that will open a browser and browse to a particular URL. If so this will do it.

    First unless you have a typelibrary for the Windows API (if you aren't sure then the answer is no you don't) you'll need this in the declarations section of the Form or Usercontrol:
    Private Const SW_SHOWDEFAULT = 10
    
    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
    

    Then the following function will open the URI passed to it:
    Private Sub BrowseTo(URL As String)
        ShellExecute 0&, vbNullString, URL, vbNullString, vbNullString, SW_SHOWDEFAULT
    End Sub
    

    The explanation:

    ShellExecute is a Windows API function that does something to a file. Just what it does varies (and is worth researching), but suffice to know that with the above parameters it will do whatever the system's default operation is for the file that is passed to URL. Because the Windows shell treats URLs it recognises in a similar manner to local files this means it does whatever the default thing to do with HTTP URLs, which is generally to open it in the default webbrowser on that system.

    Other methods might give you more control (e.g. to open it in a particular browser), in general though it's best to let the default operation take place, since that is what the system user wants to happen to HTTP URLs.


Advertisement