CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    May 2005
    Posts
    5

    Unhappy IWebBrowser2 Problem in Win32!

    I would like to show a Internet Explorer child window in my main window, and my codes are list here:
    OleInitialize(NULL);
    IWebBrowser2 * ppw = NULL;
    IOleObject * ppo = NULL;
    IOleClientSite * pmIOleClientSite = NULL;
    DWORD m_dwCookie;
    RECT rcOLE;
    rcOLE.bottom = 300;
    rcOLE.left = 0;
    rcOLE.right = 400;
    rcOLE.top = 0;
    HRESULT a;
    CoCreateInstance(CLSID_WebBrowser, NULL, CLSCTX_INPROC,IID_IWebBrowser2,(void **) &ppw);
    ppw->QueryInterface(IID_IOleObject,(void **) &ppo);
    OleSetContainedObject((IUnknown *) ppw, TRUE);
    ppo->SetClientSite(pmIOleClientSite);
    a=ppo->DoVerb(OLEIVERB_INPLACEACTIVATE, NULL, pmIOleClientSite, NULL,hWnd,&rcOLE);

    //******Always Error Here******//

    AtlAdvise(ppw, GetUnknown(), DIID_DWebBrowserEvents2, &m_dwCookie);
    ppw->Navigate(L"www.google.com", NULL, NULL, NULL, NULL);
    ppw->Release();
    OleUninitialize();
    -----------------------------------------
    It always returns an "GetUnknown--Undeclared identifier" error, and I don't know which is the base .h file.
    While I replace "GetUnknown()" to "NULL", it just runs, however, it never shows a window and seems not connected to network.....
    That's my problem, thank you!!!

  2. #2
    Join Date
    Feb 2005
    Location
    Normandy in France
    Posts
    4,590

    Re: IWebBrowser2 Problem in Win32!

    I don't know the GetUnknown function, maybe you want to use the CComCreator::GetUnknown function (i used google to see this function), but in that case you must have a CComCreator object.

    I see that you call SetClientSite with a NULL object. It is probably incorrect, you should write an object implementing IOleClientSite (yes, it needs some work).

    I hope that it can help you.

  3. #3
    Join Date
    Oct 2002
    Location
    Germany
    Posts
    6,205

    Re: IWebBrowser2 Problem in Win32!

    There is no such thing called GetUnknown that I am aware of.
    Quote Originally Posted by qexing
    //******Always Error Here******//

    AtlAdvise(ppw, GetUnknown(), DIID_DWebBrowserEvents2, &m_dwCookie);
    -----------------------------------------
    It always returns an "GetUnknown--Undeclared identifier" error, and I don't know which is the base .h file.
    The second parameter of AtlAdvise is IUnknown* of the client: which in this case is your application, I hope.

    So, if you are calling this from a COM class, pass (IUnknown*)this, or IUnknown* of the class that implements the client, something like this -
    Code:
    AtlAdvise(ppw, (IUnknown*)(this), DIID_DWebBrowserEvents2, &m_dwCookie);

  4. #4
    Join Date
    May 2005
    Posts
    4,954

    Re: IWebBrowser2 Problem in Win32!

    why you are not using the CWebBrowser2 ?
    its a wrap class its more simple to use:

    Code:
    #include "webbrowser2.h"
    CWebBrowser2 IE;
    IE.Navigate("www.codeguru.com",0,0,0,0);
    just an idea.

    for me it was ok when i needed it :-)

    Cheers
    Attached Files Attached Files

  5. #5
    Join Date
    May 2005
    Posts
    5

    Re: IWebBrowser2 Problem in Win32!

    Quote Originally Posted by golanshahar
    why you are not using the CWebBrowser2 ?
    its a wrap class its more simple to use:
    Sorry, i am just using only WIN32, so is not able to the class based on "CWnd", thank you all the same!!

  6. #6
    Join Date
    Jun 2002
    Location
    Colorado, U.S.A.
    Posts
    980

    Re: IWebBrowser2 Problem in Win32!

    Try this post.

    Kelly

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

Featured