//   Error   checking   omitted   for   clarity  
  CComPtr<IOleObject>   spOleObj;  
   
  //   Create   WebBrowser--store   pointer   in   class   member   variable   m_spWebBrowser  
  CoCreateInstance(CLSID_WebBrowser,   NULL,   CLSCTX_INPROC,   IID_IWebBrowser2,   (void**)&m_spWebBrowser);  
   
  //   Query   WebBrowser   for   IOleObject   pointer  
  m_spWebBrowser->QueryInterface(IID_IOleObject,   (void**)&spOleObj);  
   
  //   Set   client   site  
  spOleObj->SetClientSite(this);  
   
  //   In-place   activate   the   WebBrowser   control  
  RECT   rcClient  
  GetClientRect(&rcClient);  
  spOleObj->DoVerb(OLEIVERB_INPLACEACTIVATE,   NULL,   this,   0,   GetTopLevelWindow(),   &rcClient);  
   
  //   Register   container   to   intercept   WebBrowser   events  
  AtlAdvise(m_spWebBrowser,   GetUnknown(),   DIID_DWebBrowserEvents2,   &m_dwCookie);  
   
  //   Navigate   to   start   page  
  m_spWebBrowser->Navigate(L"res://webhost.exe/startpage.htm",   NULL,   NULL,   NULL,   NULL);  
posted on 2008-08-28 17:58  悠然小调  阅读(253)  评论(1编辑  收藏  举报