Delphi & C++ Builder components library
and Software development
 
 
 

Property Saver - autosave all user settings, window size and components state

Property Saver is set of non visual components which allows you to centralize and automate saving and restoring of windows position, properties of visual or non visual components and any other user defined values. Benefits:

  • it works without line of code (for standard components)
  • it's complex but very small solutions without any additional library
  • it's easy to extend to save properties of another non standard components
  • it improves your application and increase customer satisfaction

Property Saver support storing of forms and standard components settings without line of code (TForm, TEdit, TMemo, TListBox, TComboBox, TRadioButton, TRadioGroup, TCheckBox, TMenuItem). Other components can be managed by already created descendant of TCustomPropSave (TGridsPropSave, TDBGridPropSave) or you can create very easily your own component supporting any type of components (TMS, 3rd party...). Any other values can be also restored by custom code in events OnReadProperties and OnSaveProperties.

All settings are stored in INI file or compressed BZIP file. Its name can be set up at design time or runtime, so it's very easy to use this package in multi user application when users share the same application but with his own INI file and therefore with his own configuration. Custom code can be also used to store setting to DB or any stream.

Pack contains:

  • TPropSaveFile - interface components between INI file and application, usually there is only one placed on main form or datamodule
  • TPropSaveMain - main components providing storing function for one form, usually there is one placed on each form and linked to PropSaveFile
  • TGridsPropSave, TDBGridPropsSave ...- descendant components for storing of Grids, DBGrids etc., usually there is one placed on each form with component to store and linked to TPropSaveMain

Example of using

See simple example in video:
video Using of Property Saver

Save and read of user defined values

  • Open OnSaveProperties event of PropSaveMain1 and add code:
    PropSaveFile1.WriteString(Key,'LastFile',SomeVariable);
  • Open OnReadProperties of PropSaveMain1 and add code:
    SomeVariable:=PropSaveFile1.ReadString(Key,'LastFile','noname.ini');

Reset application to default values

All settings are stored in one file, by default it is in directory with application and has name "appname.ini". For resetting use following code:
PropSaveFile1.Clear; // clear contents of ini file
PropSaveFile1.SaveFile(''); // save empty file
PropSaveFile1.DisableAll:=true; // don't save properties until close app
ShowMessage('Close the application and run again with default values.'); // inform user

Create new PropSave component for saving properties of another type of components

For automatic re/storing of another components create new PropSave Components.
  • Use TCustomPropSave as parent component
  • Override two procedures
    protected
      procedure ReadSaveProps(A: TPropSaveAction; PSFile: TPropSaveFile; Key: string; Comp: TComponent); override;
    public
      function CanSave(Comp: TComponent): boolean; override;

See GridsPropSave.pas file for example.

Open documentation page.

Go back