Results 1 to 4 of 4

Thread: How do I NAVIGATE an external Internet Explorer_Server class??

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2006
    Posts
    2

    Exclamation How do I NAVIGATE an external Internet Explorer_Server class??

    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
    Last edited by rfaricy; Feb 9th, 2006 at 03:32 AM. Reason: typos

  2. #2

    Thread Starter
    New Member
    Join Date
    Feb 2006
    Posts
    2

    Re: How do I NAVIGATE an external Internet Explorer_Server class??

    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?

  3. #3
    Fanatic Member
    Join Date
    Jan 2005
    Location
    In front of this pc.
    Posts
    580

    Re: How do I NAVIGATE an external Internet Explorer_Server class??

    The attached project should give you everything you need. Note that it will also provide access to Windows Explorer windows as well as IE windows unless you check the window class before adding the window to the collection.
    Attached Files Attached Files
    What bug? That's not a bug. It's an undocumented feature!

  4. #4
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    Re: How do I NAVIGATE an external Internet Explorer_Server class??

    Great code anotherVBnewbie !
    It very nicely controls an external IE window.

    However, rfaricy's original question was,
    I have an application that needs to read information from an existing web browser window (located within an application I did not create).
    I guess he is talking about Webbrowser Controls embedded in another application (like Yahoo Messanger PM window). I'm very interested in this topic too. I have searched Google a lot but didn't find anything usefull.

    Could you please give any idea how to navigate an external webbrowser control ?
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


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