سؤال

I have mshtml hosted in my c++ app. I tried to query the IHTMLDocument for IOmNavigator but got back nothing. I also tried to do the same with IHTMLWindow2 with no luck.

I am trying to access IOmNavigator to get browser version number. Any help would be greatly appreciated.

Thanks

هل كانت مفيدة؟

المحلول

IHTMLDocument2 *pDoc; IHTMLWindow2 *ihw; IOmNavigator *nvg; BSTR uastr; AnsiString mouni;
if (SUCCEEDED(CppWebBrowser1->Document->QueryInterface(IID_IHTMLDocument2,(void**)&pDoc)))
{
  pDoc->get_parentWindow(&ihw); ihw->get_navigator(&nvg); nvg->get_userAgent(&uastr);
  mouni=AnsiString(uastr).UpperCase(); nvg->Release(); ihw->Release(); pDoc->Release();
  if (mouni.Pos("TRIDENT")>0 && mouni.Pos("MSIE")==0) { lmrg=8; tmrg=8;}
}

Code snip above (BCB5) shows how to get IHTMLDocument2 interface, then the IHTMLWindow2 interface, then the IOmNavigator interface, then the useragent string, and set some margins accordingly (IE11 is different to IE10 and previous versions in the way it renders pages). HTH, Graphic.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top