Hi, I've been making a small embedding sample on win32, sort of in the spirit of the "minimal workable embedding example" posted here earlier for gtk. However I also wanted to take a first stab at wrapping many of the 'complicated' embedding calls in a simpler API as seen from the application. Maybe this can serve as input for the discussion about embedding APIs later this week :)
I've posted about it at http://pellej.com/?p=41 where you can also download the VC++ 2005 project. (finally made me revive my old blog and update to WP 2.5) I'll inline the essence of the API header here as well. -Pelle class MozEmbed { public: MozEmbed(); virtual ~MozEmbed(); nsresult CreateBrowser(void* aNativeWindow, PRInt32 x, PRInt32 y, PRInt32 width, PRInt32 height); nsresult SetPositionAndSize(PRInt32 x, PRInt32 y, PRInt32 width, PRInt32 height); nsresult LoadURI(const char* uri); nsresult SetFocus(PRBool focus); void SetListener(EmbedListener* pNewListener); EmbedListener* GetListener(); void* GetNativeWindow(); private: nsresult InitEmbedding(); EmbedListener* pListener; void* nativeWindow; nsCOMPtr<nsIWebBrowser> webBrowser; nsCOMPtr<nsIWebNavigation> webNavigation; nsCOMPtr<nsIWebBrowserChrome> chrome; }; /** * This is the callback interface to the embeddig app. * The app can subclass this and override methods that will * be called as appropriate. * * Use MozEmbed::SetListener to regster the listener * * EmbedListener implements noop defaults, so the app only * needs to override the methods it uses. */ class EmbedListener { public: EmbedListener(); virtual ~EmbedListener(); void SetMozEmbed(MozEmbed* pAMozEmbed); // methods the embedding app can override virtual void SetTitle(const char* newTitle); protected: MozEmbed* pMozEmbed; }; _______________________________________________ dev-embedding mailing list [email protected] https://lists.mozilla.org/listinfo/dev-embedding
