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!!!
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).
There is no such thing called GetUnknown that I am aware of.
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 -
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.