Results 1 to 3 of 3

Thread: Open URL in browser

  1. #1

    Thread Starter
    Member VbAndersonic's Avatar
    Join Date
    Aug 2001
    Location
    Derby, UK
    Posts
    58

    Unhappy Open URL in browser

    Does anyone know how to send a URL to an already open window of a browser? At the moment i have to close the original window then open a new window with the new URL i want. Help!

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    I presume you are asking how to do this in VB. If so, it is easy. I have several programs that either open a browser, and connect to a web page, or, if the browser is already open, go to a designated web page, all with one mouse click. I have developed my own web address book in VB, and have my favorite web sites displayed in a listview control. All I do is click on the web site I want, and my program takes me there. Place the following in the declarations section of a form:

    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

    In a button click event, put:

    Dim OpenPage As Long

    OpenPage = ShellExecute(frmWebSites.hWnd, "Open", "http://forums.vb-world.net/", 0&, 0&, 0&)

    Substitute frmWebSites with the name of your form, and substitute the web address with the address of your choice. In my code, the web address is actually a variable that is set in the click event of the listview control. Hope this helps.

  3. #3

    Thread Starter
    Member VbAndersonic's Avatar
    Join Date
    Aug 2001
    Location
    Derby, UK
    Posts
    58
    Hey thanks! I used the ShellExecute method before and all it did was open a new instance of the browser. I have no idea how it works now, but thanks!

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