SaveEnvironment - cCJCommandBarSystem
Saves layout information from the CommandBar system object
Type: Procedure
Syntax
Procedure SaveEnvironment
Call Example
Send SaveEnvironment
Description
SaveEnvironment saves layout information from the commandbar system object. This is used to save a user's menu/toolbar configuration. By default this information is saved to the registry. SaveEnvironment is called when a cCJCommandBarSystem object is deactivated (see ReleaseComObject). By default, SaveEnvironment does the following:
-
If a cApplication object does not exist or that application object's pbPreserveEnvironment property is false, it returns and does nothing.
-
It determines what should be saved by checking the peRestoreLayout property.
-
It determines the registry location of the data to be saved by calling the cApplication object's RegistryKeyString property.
-
If saves the layout by calling SaveLayoutToRegistry passing the layout and registry key data.
Saving to the Registry
By default SaveEnvironment saves to the registry and you do not need to make any changes. As a reference the source for this method is:
Procedure SaveEnvironment
Handle eLayout
String sKey
Boolean bPreserveEnvironment
If (ghoApplication=0) Begin
Procedure_Return
End
Get pbPreserveEnvironment of ghoApplication to bPreserveEnvironment
If bPreserveEnvironment Begin
Get peRestoreLayout to eLayout
Get RegistryKeyString of ghoApplication to sKey
Send SaveLayoutToRegistry eLayout sKey
End
End_Procedure
Saving to an XML File
You may wish to augment and override this method to support custom save behaviors. For example, if you wished to save the data to an XML file, you could make changes as follows:
Procedure SaveEnvironment
Handle eLayout
String sFileName
Boolean bPreserveEnvironment
If (ghoApplication=0) Begin
Procedure_Return
End
Get pbPreserveEnvironment of ghoApplication to bPreserveEnvironment
If bPreserveEnvironment Begin
Get peRestoreLayout to eLayout
// create a file name for the XML file.
Move "C:\MyLayout\Layout1.xml" to sFileName
// Get the layout from the xml file.
Send SaveLayoutToRegistry eLayout sFileName
End
End_Procedure
In this example, SaveLayoutToXML is used in place of SaveLayoutToRegistry.
See Also