# BrowserFlags -- Customizing the behavior of ActiveX/OLE documents

Last Updated at 23-Jun-97 (SatoNa)

After releasing IE 3.0, we have received several requests from our customers (especially large accounts, such as BBC) that they don't like the fact that IE always opens Office documents (which are ActiveX documents) in-place. They want to configure the IE so that it opens certain types of documents using the application's frame window (instead of in-place-navigate in the IE frame).

We've also encountered several bugs in application programs during the development of IE 3.0, which required special code in the browser side to work around those bugs. For IE 3.0, we hard coded ProgIDs of those applications and were not extensible.

For IE 4.0 (and IE 3.01 as well), we added a feature to specify a set of minor behaviors changes in the browser side for a particular application program (based on its ProgID). The user (or the setup program of an application program) may put a named DWORD value ("BrowserFlags") under the ProgID key of the application program (e.g., "Excel.Sheet.8" for Excel97). This DWORD may contain a combination of following flags.

- 0x00000001 BROWSERFLAG_OPENCOPY
- 0x00000002 BROWSERFLAG_OPENVERB
- 0x00000004 BROWSERFLAG_SETHOSTNAME
- 0x00000008 BROWSERFLAG_DONTINPLACE
- 0x00000020 BROWSERFLAG_DONTUIDEACTIVATE
- 0x00000040 BROWSERFLAG_NEVERERASEBKGND
- 0x00000080 BROWSERFLAG_PRINTPROMPTUI
- 0x00000200 BROWSERFLAG_INITNEWTOKEEP
- 0x40000000 BROWSERFLAG_MSHTML
- 0x80000000 BROWSERFLAG_REPLACE

BROWSERFLAG_OPENCOPY: This flag is needed for Excel in Office 95 (ProgID = "Excel.Sheet.5" or "Excel.Chart.5"). Simply binding to an excel file (which initializes the object via IPersist::Load) and opening it as an embedding confuses Excel and causes GPF. When this flag is set, the browser creates a copy of the object (by calling OleCreateFromData) and activate the copy instead of the original object.

BROWSERFLAG_OPENVERB: This flag is needed for Sound Recorder (ProgID = "SoundRec"), which does not provide any UI (to stop playing) if we activate it with OLEVERB_PRIMARY.

BROWSERFLAG_SETHOSTNAME: This flag is needed for Word in Office 95 (ProgID = "Word.Document.6"), which does not work as an embedding unless IOleObject::SetHostName is called.

BROWSERFLAG_DONTINPLACE: We also provide an UI for the end-user to control this flag from File-Type dialog box (select View->Options menu after opening the MyComputer). Select the application in the list and click Edit button. At the bottom right (right above the OK button), you'll see a check-box titled "Browse in same window", which is checked (enabled) by default.

BROWSERFLAG_DONTUIDEACTIVATE: This is a work around for Word, Powerpoint and Excel in Office 97. Those apps don't support UI-deactivation correctly and calling IOleDocumentView::UIActivate(FALSE) causes some problems. If this flag is set, the browser calls IOleInPlaceActiveObject::OnDocWindowActivate(FALSE) instead.

BROWSERFLAG_NEVERERASEBKGND: This is an optimization flag to avoid extra painting when the ActiveX document paints the entire rectangle the host give (via IOleDocumentView::SetRect).

BROWSERFLAG_PRINTPROMPTUI: This is a work around for Powerpoint 97. It fails to print if we call IOleCommandTarget::Exec(OLECMDID_PRINT) with PRINTFLAG_PRINTPROMPTUI. If this flag is set, the browser always removes this flag before calling Exec(OLECMDID_PRINT).

BROWSERFLAG_INITNEWTOKEEP: This is a work around for Excel 97. When the browser opens an ActiveX document, it calls IClassFactory::LockServer to keep the server running for a while. Since Excel does not implement it correctly, it shuts down immediately. If this flag is set, we create an extra instance and call its IPersistStorage::InitNew.

BROWSERFLAG_MSHTML (private): This is a special flag for the browser to distinguish ActiveX documents created by MSHTML.DLL. The browser has some specific code (such as pre-merged menu) for this case and this flag enable it. This flag must not set for any other types of ActiveX documents.

BROWSERFLAG_REPLACE: This flag has no effect unless the browser already have a set of browser flags for the type of document (such as Word97 and Excel97). When dealing with those "known" types, the browser retrieves browser flags from the registry and perform an OR operation with the flags from its built-in table unless this flag is set. If this flag is set, the flags in the built-in table is ignored and flags from the registry will be used.

Go to the home page