As part of learning the existing embedding APIs i decided to clone the 
existing winEmbed sample using MFC. The attached zip file contains the 
necessary source files. Please unzip to a dir named "mfcembed" under the 
mozilla/embedding/tests dir. You should be able to build/run it the 
usual way.

Here's how this implementation differs from that of winEmbed:

    * Use's MFC's Frame/View to create/manage the embedded browser. 
      winEmbed uses a dialog resource to do the same.
    * This does not use the nsIWebBrowserChrome's CreateBrowserWindow() 
      memberto do the embedded browser's creation - the browser is 
      created as part ofthe MFC window's view creation. The 
      nsIWebBrowserChrome implementation doesnothing in this sample 
      except for the SetStatus() member. (Essentially thisimplementation 
      mirrors that of the ActiveX control). Taking this approach keeps 
      the embedded browser creation/destruction code in one place and 
      keeps the code simple to understand for beginners
    * nsIBaseWindow implementation does nothing in this sample(Again 
      similar to what the ActiveX control does). WinEmbed's 
      implementation redirects calls to the nsIBaseWindow it retrieves 
      from nsIWebBrowser.
    * This sample updates the window title after a page is loaded
    * Can create multiple browser windows (Ctrl-N). WinEmbed has a menu 
      item to do this, but i could never get it to work
    * I've taken some shortcuts such as to access some member vars 
      directly etc. in places mainly to reduce additional getters/new 
      interfaces to keep the code simple - which the OO purist in you 
      may frown upon.
      
I'd appreciate any feedback you may have on this...

Thanks
Chak

mfcembed.zip

Reply via email to