I found this example http://www.mvps.org/user32/webhost.cab that host an Internet Explorer WebBrowser object, and it uses this code to access the object
void webhostwnd::CreateEmbeddedWebControl(void)
{
OleCreate(CLSID_WebBrowser,IID_IOleObject,OLERENDER_DRAW,0,&site,&storage,(void**)&mpWebObject);
mpWebObject->SetHostNames(L"Web Host",L"Web View");
// I have no idea why this is necessary. remark it out and everything works perfectly.
OleSetContainedObject(mpWebObject,TRUE);
RECT rect;
GetClientRect(hwnd,&rect);
mpWebObject->DoVerb(OLEIVERB_SHOW,NULL,&site,-1,hwnd,&rect);
IWebBrowser2* iBrowser;
mpWebObject->QueryInterface(IID_IWebBrowser2,(void**)&iBrowser);
VARIANT vURL;
vURL.vt = VT_BSTR;
vURL.bstrVal = SysAllocString(L"http://google.com");
VARIANT ve1, ve2, ve3, ve4;
ve1.vt = VT_EMPTY;
ve2.vt = VT_EMPTY;
ve3.vt = VT_EMPTY;
ve4.vt = VT_EMPTY;
iBrowser->put_Left(0);
iBrowser->put_Top(0);
iBrowser->put_Width(rect.right);
iBrowser->put_Height(rect.bottom);
iBrowser->Navigate2(&vURL, &ve1, &ve2, &ve3, &ve4);
VariantClear(&vURL);
iBrowser->Release();
}
I don't have much experience with cpp, I want to know how to access that same ie object (to use Navigate2 for example) from a button or something like that. How could I achieve this?