Demo1 - Basics
Aim of demo:
This demo shows the basic idea of PtSettings. It is meant to show:
what settings groups are.
how settings are made.
how a storage is used.
What it does:
Demo1 uses an .ini file as a storage. The settings contain positions for forms and user info consisting of integer, string and enumerated settings.
How it's done:
Looking at Demo1Settings.pas :
- Settings groups:
- The classes TUserSettings, TFormSettings, TGUISettings and TSettings are types of settings groups. They all inherit from TSettingsGroup.
- Of the settings groups, Settings is the root object of the settings structure. It has the sub groups User and GUI. The settings group GUI has two sub groups MainForm and OtherForm, both of type TFormSettings.
- In the constructors you can see how child objects are created and attached.
- After running Demo1, you can see in the settings saved from these sections in the .ini file that Demo1 generates.
- The settings that are to be saved are all published properties. If you want properties to not be saved, then make them public.
- In procedure InitializeSettings we see that Demo1 stores its settings in an .ini file because Storage is of type TIniSettingsStorage.
- We load all the settings by calling Storage.LoadAll( Settings );.
- We save all the settings by calling Storage.SaveAll( Settings );.
Extra:
Do not explicitly free child settings groups. TSettingsGroup objects automatically free their sub groups when destroyed.