title: Custom Download Manager IWebbrowser2
body: <p>Sorry if my question is previously answered here but I have, for days, searched the internet including SO with no solution.</p>
  
  <p>Basically I want to Implement Download Manager for IE webbrowser control (Not IDE itself).
  I have read a lot on MSDN and among them is <a href="http://msdn.microsoft.com/en-us/library/aa753618%28v=vs.85%29.aspx" rel="nofollow">this link</a> which shows how to create it.
  The Problem with this example (and my problem in that case) is where do I register/apply the IServiceProvider to my web browser. The Article does not say. However searching I found <a href="http://www.archivum.info/microsoft.public.vc.atl/2006-02/00064/Re-How-To-Implement-IServiceProvider-and-IDownloadManager.html" rel="nofollow">this question</a> and it say I quote  </p>
  
  <blockquote>
    <p>Use CAxWindow::QueryHost to get IObjectWithSite pointer. Call SetSite 
    passing your IServiceProvider implementation.</p>
  </blockquote>
  
  <p>Unfortunately I don't use or know anything about ATL as I use wxWidgets. So where do I get that in wxWebview or "vanilla" MS COM?</p>
  
  <p>here is what I have so far</p>
  
  <pre><code>HRESULT wxDownloadMgr::Download(IMoniker *pmk, IBindCtx *pbc,DWORD dwBindVerb,  
                    LONG grfBINDF,BINDINFO *pBindInfo, LPCOLESTR pszHeaders,LPCOLESTR pszRedir,UINT uiCP )
  {
      // Get URL
      LPOLESTR urlToFile;
      HRESULT result = pmk-&gt;GetDisplayName( pbc, NULL, &amp;urlToFile ); 
      //OLECHAR is simply a wchar_t and an LPOLESTR is a wide character string (e.g. wchar_t*). 
      wxString url(urlToFile);
      wxWebViewEvent event(wxEVT_COMMAND_WEB_VIEW_DOWNLOAD_BEGINS,GetId(), url, ""); 
      event.SetEventObject(this);//WHICH OBJECT TO SET HERE????????
      HandleWindowEvent(event);
  
      ::MessageBox(NULL,"Download","Download Manager",MB_OK);
      return S_OK;
  } 
  
  STDMETHODIMP wxServiceProvider::QueryService(REFGUID guidService,
                                              REFIID riid,
                                              void **ppv)
  {
      HRESULT hr = E_NOINTERFACE;
  
      if (guidService == SID_SDownloadManager &amp;&amp; riid == IID_IDownloadManager)
      {
          // Create new DownloadMgr object using ATL.
          CComObject&lt;wxDownloadMgr&gt;* pDownloadMgr;
          hr = CComObject&lt;wxDownloadMgr&gt;::CreateInstance(&amp;pDownloadMgr);
  
          // Query the new CDownloadMgr object for IDownloadManager interface.
          hr = pDownloadMgr-&gt;QueryInterface(IID_IDownloadManager, ppv);
      }
  
      return hr;
  }
  </code></pre>