Hi,
Sipman, This is great!!!! Thanks a lot. I will try this out and update you with
the results.
Adam, do you have any updates on this?
Thanks,
Ram.
sipman wrote:
> -----Original Message-----
> From: Chak Nanga <[EMAIL PROTECTED]>
> Newsgroups: netscape.public.mozilla.embedding
> To: sipman <[EMAIL PROTECTED]>
> Date: Saturday, February 17, 2001 11:15 AM
> Subject: Re: mfcEmbed & chrome
>
> Here's something Adam Lock posted to this newsgroup a while ago regarding
> this topic. I can't guarantee that this works since i have'nt
> tried it myself(and all the embedding API changes we've had since Adam's
> posting). You may want to give it a try though.
>
> Thanks
> Chak
>
> Subject:
> How to use chrome in embedding apps
> From:
> Adam Lock <[EMAIL PROTECTED]>
> Date:
> Wed, 02 Aug 2000 17:46:06 +0100
> Newsgroups:
> netscape.public.mozilla.embedding
>
> Hi all,
> This is a quick note to describe how chrome and embedding work at the moment
> to give some ideas how you might use it.
>
> As you may know from Mozilla the application the chrome dictates the entire
> look and feel of the application. Chrome generally comprises of XUL (the
> layout structure), Javascript (the program logic), CSS (the layout style or
> "skin") and DTD (the language locales). Generally the structure/logic, the
> style/skin and the locale are in separate places.
>
> What I've done is put together some simple generic embedding chrome suitable
> for when Gecko is embedded into someone else's window. It has a few popup
> menus and some simple buttons. This chrome lives in
> mozilla\embedding\browser\chrome. I call it generic because most embedders
> will likely want to modify it in some way - adding extra menu options,
> removing the toolbar or whatever.
>
> The embedding chrome consists of:
>
> mini-nav.xul - defines toolbars, buttons, popup menus and the content area
> mini-nav.js - initialisation code and methods for handling menu and button
> clicks
> embedding.dtd - Locale specific language strings for menu items and button
> labels
> embedding.css - Style information including bitmaps to place on the toolbar
> buttons.
> The embedding chrome is not built by default, so the first thing you must do
> is:
> cd mozilla\embedding\browser\chrome
> nmake /f makefile.win
>
> This copies the chrome files to Mozilla's chrome folder. The next step is
> run Mozilla so that it updates its list of what skins, packages and
> languages are installed on this system. You can do this and test the chrome
> at the same time by typing:
>
> cd mozilla\dist\win32_d.obj\bin
> mozilla -chrome chrome://embedding/browser/content/mini-nav.xul
>
> Mozilla will run, but it will use the embedding chrome. It should have a
> toolbar with back, forward, reload, stop and an address bar and a popup menu
> with back, forward, stop and reload. It will probably get some more stuff in
> time. Testing embedding chrome in Mozilla is a great way to see if its
> working or not because JavaScript errors get printed to the console -
> something you won't get in the embedding app.
>
> So how do you use the chrome in your own embedding application?
>
> First of all, you must tell your webbrowser object that it will be hosting
> chrome as opposed to content. Add this in your webbrowser initialisation
> code but *before* you call nsIBaseWindow::Create():
>
> nsCOMPtr<nsIDocShellTreeItem>
> browserAsItem(do_QueryInterface(mWebBrowser));
> browserAsItem->SetItemType(nsIDocShellTreeItem::typeChromeWrapper);
>
> This tells the webbrowser object that it should create a root docshell for
> hosting chrome, which has more privileges that normal content. Without this
> line popup menus won't work because DOM events don't "bubble" correctly and
> you may also run into security issues.
>
> Next, you load the chrome like you would any other URL:
>
> mWebBrowserAsNav->LoadURI("chrome://embedding/browser/content/mini-nav.xul")
> ;
>
> Your chrome will load and be visible in the window.
>
> To load some content (e.g. when the user clicks on a link in another
> window), you want it to happen in the content area in the middle of the
> chrome and not replace the chrome itself. This means you have to obtain the
> content areas nsIWebNavigation interface and call LoadURI on that. This is
> done like this:
>
> nsCOMPtr<nsIDocShellTreeItem>
> browserAsItem(do_QueryInterface(mWebBrowser));
> nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
> browserAsItem->GetTreeOwner(getter_AddRefs(treeOwner));
> nsCOMPtr<nsIDocShellTreeItem> contentItem;
> treeOwner->GetPrimaryContentShell(getter_AddRefs(contentItem));
> nsCOMPtr<nsIWebNavigation> contentItemAsNav(do_QueryInterface(contentItem));
> contentItemAsNav->LoadURI("http://www.mozilla.org");
>
> So that's how to use chrome in embedding. Otherwise it's pretty much the
> same as loading any other URL.
>
> I encourage you to play with the chrome and see if you can change the menu
> options, hide the toolbar and so on. Hopefully, you'll see that it's pretty
> powerful stuff! The www.mozilla.org website and the
> netscape.public.mozilla.ui and netscape.public.mozilla.xpfe newsgroups are
> good places to find answers to general chrome questions.
>
> I'm currently working on some enhancements to the embedding chrome that will
> make it easier for the embedder and the chrome javascript to talk back and
> forth. When this in place it will be simple for Javascript code to call into
> the C++ embedding site to perform native actions when a menu option is
> selected for instance.
>
> sipman wrote:
>
> Hi.Is there any way i can get mfcEmbed to display a chrome ? If i can do
> itthrough xul/xbl it is fine but if not a c++ code will also be fine. I
> ammostly interested in the layout not the rendering. i.e create a frame, put
> asplitter , treewindow and grid window as a start application . All
> eventsare handled though c++ in the worst case. If this is not possible
> what isthe show stopper ?