Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I want to give my user the ability to provide the url of a web page. I load ie using the following code:

 

Dim IE As New SHDocVw.InternetExplorer

IE.Visible = True

IE.Navigate("www.msn.com")

 

Now, I want my program to wait until ie is closed, and then I want to capture the url at the time of closing. So, how do I wait for ie to complete and is there an ie event such as beforeclosing that will allow me to get the location property?

 

Please note that I am NOT using the web browser control but rather launching a copy of ie (to make the user's favorites and web history available).

 

Thanks!

Posted (edited)

Well, here is the answer

 

1. Dim a variable with form-level scope to hold the ie object when needed along with a form-level variable to hold the url:

 

Dim IE As SHDocVw.InternetExplorer ' Do not use "new" nere; instantiate only as needed

Dim URL As String

 

2. Create a handler for the OnQuit event that takes no arguments:

 

Sub HandleIEQuit()

URL = IE.LocationURL

Dim x As Integer = 1

End Sub

 

3. Assign a limited-scope handler delegate in the subroutine or procedure creating the browser call:

 

Private Sub AddURL_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles AddURL.ItemClick

URL = ""

IE = New SHDocVw.InternetExplorer

AddHandler IE.OnQuit, AddressOf HandleIEQuit

IE.Visible = True

IE.Navigate("www.msn.com")

End Sub

 

4. The delay cab be handled in a variety of ways, but after second thought I decided to eliminate the possibility of creating an unexpected "hang" for my users if they forget to close the browser window.

Edited by heabrams

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...