Click to See Complete Forum and Search --> : IWebBrowser2 Problem in Win32!


qexing
June 26th, 2005, 08:42 AM
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!!!

SuperKoko
June 26th, 2005, 11:24 AM
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.

Siddhartha
June 26th, 2005, 11:30 AM
There is no such thing called GetUnknown that I am aware of.

//******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 -

AtlAdvise(ppw, (IUnknown*)(this), DIID_DWebBrowserEvents2, &m_dwCookie);

golanshahar
June 26th, 2005, 11:38 AM
why you are not using the CWebBrowser2 ?
its a wrap class its more simple to use:


#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

qexing
June 26th, 2005, 10:28 PM
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!!

Runt888
June 27th, 2005, 07:08 PM
Try this post. (http://www.codeguru.com/forum/showthread.php?t=227360)

Kelly