By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,693 Members | 1,255 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,693 IT Pros & Developers. It's quick & easy.

How to NAVIGATE an external Internet Explorer_Server class

P: n/a
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
Feb 9 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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?

Ryan Faricy wrote:
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

Feb 9 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.