Saving and Restoring a Layout
A user’s layout may be saved and restored when the program is run again. Two properties control whether layouts are saved and restored: the cApplication’s pbPreserveEnvironment property and the cCJCommandBarSystem’s peRestoreLayout property. peRestoreLayout supports different levels of save/restore (none, restore layout of menubar/toolbars, restore layout of customized menu items, etc.).
When enabled, layout information is saved to the HKEY_CURRENT_USER registry branch. This entire process is automatic and requires no extra programming.
You can augment the main save and restore procedures (LoadEnvironment and SaveEnvironment) to save and load layouts to different locations. For example, you could change the methods to save and restore to an XML file by sending the messages LoadLayoutFromXML and SaveLayoutToXML.
Procedure LoadEnvironment
Handle eLayout
String sKey
Boolean bOk 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
Get LoadLayoutFromRegistry eLayout sKey to bOk
End
End_Procedure
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
You can also save and load layouts by sending the messages LoadLayoutFromRegistry and SaveLayoutToRegistry.