How to NAVIGATE an external Internet Explorer_Server class

R

Ryan Faricy

I am in need of help here ... I have an application that needs to read
information from an existing web browser window (located within an
application I did not create). I am able to read the text from it using
the IEDom tutorial seen everywhere ...

.... but now what I need it to do is to actually navigate to a different
page.

I have attempted to create an object within my application that points
to the Internet Explorer_Server class' IWebBrowser2, almost identically
to the routine that gets the IHTMLDocument class so that I can read my text.

The only problem is, when it gets to "If hr Then Throw New
COMException(hr)", it (obviously) throws an exception. Everything else
seems to be working great.

I know the function shouldn't return an "Object" but rather a
WebBrowser. Right? I just happened to have forgotten to change it back
before I pasted it here.

What am I doing wrong? How can I subclass another applications "Internet
Explorer_Server" in order to tell it to go to a certain URI?

Public Module IEBrowser
Declare Function ObjectFromLresult Lib "oleacc" (ByVal lResult As
Int32, ByRef riid As System.Guid, ByVal wParam As Int32, ByRef ppvObject
As IHTMLDocument) As Int32
Dim win32 As New Win32Functions()

Public Function IEBrowserFromhWnd(ByVal hWnd As IntPtr) As Object
Dim IID_IWebBrowser2 As System.Guid = New
System.Guid("D30C1661-CDAF-11D0-8A3E-00C04FC9E26E")
'Dim hWndChild As Int32
Dim lRes As Int32
Dim lMsg As Int32
Dim hr As Int32
If Not hWnd.Equals(0) Then
If Not hWnd.Equals(0) Then
' Register the message
lMsg =
MDC.Win32Functions.RegisterWindowMessage("WM_HTML_GETOBJECT")
'MsgBox(lMsg.ToString)
' Get the object
Call MDC.Win32Functions.SendMessageTimeout(hWnd, lMsg,
0, 0, MDC.Win32Functions.SMTO_ABORTIFHUNG, 1000, lRes)

If lRes Then
' Get the object from lRes
hr = ObjectFromLresult(lRes, IID_IWebBrowser2, 0,
IEBrowserFromhWnd)
If hr Then Throw New COMException(hr)
End If
End If
Else
MsgBox("bad hwnd!!")
End If
End Function
End Module
 
R

Ryan Faricy

Okay, I've switched to IHTMLDocument2 and it has the Navigate method.
But when I go pass it a URL, it doesn't do anything.

Help?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top