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!!!
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.
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);
2 Attachment(s)
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
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!!
Re: IWebBrowser2 Problem in Win32!