Skip to main content

Saving and Restoring Bar Layout Automatically

  • 2 minutes to read

The ExpressBars Suite allows you to automatically preserve the bar layout between application runs in an INI file, or the system registry.

Please refer to the Saving and Restoring Bar Layout Manually topic for information on how to save and restore bar layout manually.

A bar manager can automatically save a bar layout to an INI file, or the system registry when the form that contains the bar manager is being closed, and restore it when the form loads. This functionality is disabled by default. To activate it, you need to specify the destination storage device and location for the information being stored:

  • An INI file. Set the bar manager’s StoreInIniFile property to True and designate the filename using the IniFileName property. You can specify the full path to the filename in order to store the file to a specific location, other than the application’s starting folder. You can also use paths relative to the application’s starting folder.

  • The system registry. Set the bar manager’s StoreInRegistry property to True and designate the registry path using the RegistryPath property. Values of this property are automatically formatted, and represent the registry keys relative to the HKEY_CURRENT_USER root key.

At design time you can click an ellipsis button within the Object Inspector to invoke the Developer Express Registry path property editor that allows you to create a new registry key, or select an existing registry key within the HKEY_CURRENT_USER\Software\ key.

The following code snippet demonstrates how to designate the registry as the storage device, and save a bar layout to the HKEY_CURRENT_USER\Software\Developer Express\Delphi registry key.

dxBarManager1.StoreInRegistry := True;
  dxBarManager1.RegistryPath := 'Software\Developer Express\Delphi';

Note

When both an INI file and the registry are used to store and restore the bar layout, the information is stored/restored to/from the registry first, and then to/from the specified INI file. In this instance, the settings from an INI file override the settings that have been acquired from the registry.

Important

The automatic saving/loading of the bar layout is only possible if the bar manager belongs to a TForm or TFrame class instance. Otherwise, you need to manually save/restore settings as described in the Saving and Restoring Bar Layout Manually topic.

See Also