Sign in Join
FPDoc Onlineexperiment

TXMLPropStorage class

In unit XMLPropStorage

Implements a class for XML storage of Form Session properties.

Declaration

pascal
TXMLPropStorage = class(TCustomXMLPropStorage)

Inheritance

  1. TXMLPropStorage
  2. TCustomXMLPropStorage
  3. TFormPropertyStorage
  4. TControlPropertyStorage
  5. TCustomPropertyStorage
  6. TComponent
  7. TPersistent
  8. TObject

Description

TXMLPropStorage is a TCustomXMLPropStorage descendant used to save or restore properties values using an XML file. It introduces new properties, methods, and members needed to read or write values in an XML file.

Values read or written using the class are defined in the SessionProperties for a TForm or TFrame instance. At design-time, use the SessionProperties property editor in the Object Inspector to maintain the property names. At run-time, the property names can be assigned using a string like:

Form1.SessionProperties := 'Width;Height;Image1.Width';

Use the FileName property to specify where the XML content is stored.

Use the RootNodePath property to specify the path to a node in the XML document where the XML content is stored.

At run-time, default handler routines (attached to the parent form) are used to Save or Restore the content in the XML file.

Use the StoredValues property to specify property names which cannot be assigned to the form session properties using the Object Inspector. It can be used for properties which cannot be represented as a singular value or do not have published visibility. Use the OnSavingProperties and OnRestoreProperties event handlers to store or restore (respectively) the values for these items in StoredValues.

TXMLPropStorage can alo be used to save and restore properties for TFrame instances on a form, but it requires some additional coding. The RootNodePath must be specified to identify the path where the TFrame values are stored. In addition, the SessionProperties for the frame must be assigned in an overridden constructor and the Restore method must be called to reload the values. The Save method method also be called in na overridden Destructor for the frame.

A demonstration program is located in the examples/propstorage/ directory.

A tutorial for TXMLPropStorage is located on the Lazarus Wiki at:

https://wiki.lazarus.freepascal.org/TXMLPropStorage

Use TINIPropStorage or TJsonPropStorage components to save and restore session properties using either a .INI file or a JSON (JavaScript Object Notation) file.

See also

Properties

StoredValuespublishedCollection with the names and values for properties handled for the container.
FileNamepublishedName of the file where the property data is saved in XML format.
RootNodePathpublishedPath to the root node in the XML file.
ActivepublishedIndicates whether the container is Active and allows access to its storage.

Events

OnSavingPropertiespublishedEvent handler signalled when the Save method is started.
OnSavePropertiespublishedEvent handler signalled when the Save method is completed.
OnRestoringPropertiespublishedEvent handler signalled when the Restore method is started.
OnRestorePropertiespublishedEvent handler signalled when the Restore method is completed.

Inherited

From TCustomXMLPropStorage (9)

DoEraseSections DoReadString DoWriteString FixPath FreeStorage GetXMLFileName RootSection StorageNeeded XMLConfig

From TFormPropertyStorage (2)

Create Destroy

From TControlPropertyStorage (1)

GetPropertyList

From TCustomPropertyStorage (22)

DoReadInteger DoWriteInteger EraseSections FinishPropertyList GetRoot OnSaveException ReadBoolean ReadInteger ReadRect ReadString ReadStrings Restore RestoreProperties Root Save SaveProperties StoredValue WriteBoolean WriteInteger WriteRect WriteString WriteStrings

From TComponent (74)

_AddRef _Release BeforeDestruction CanObserve ChangeName ComObject ComponentCount ComponentIndex Components ComponentState ComponentStyle DefineProperties DesignInfo DestroyComponents Destroying ExecuteAction FindComponent FreeNotification FreeOnRelease GetChildOwner GetChildParent GetChildren GetDeltaStreams GetEnumerator GetIDsOfNames GetNamePath GetObservers GetOwner GetParentComponent GetTypeInfo GetTypeInfoCount HasParent iicrGetComponent InsertComponent Invoke IsImplementorOf Loaded Loading Name Notification ObserverAdded Observers OnGetDeltaStreams Owner PaletteCreated QueryInterface ReadDeltaState ReadDeltaStream ReadState ReferenceInterface RemoveComponent RemoveFreeNotification RemoveFreeNotifications SafeCallException SetAncestor SetChildOrder SetDesigning SetDesignInstance SetInline SetName SetParentComponent SetSubComponent Tag ToString TToStringNameMode UpdateAction Updated UpdateRegistry Updating ValidateContainer ValidateInsert ValidateRename VCLComObject WriteState

From TPersistent (5)

Assign AssignTo FPOAttachObserver FPODetachObserver FPONotifyObservers

From TObject (37)

AfterConstruction CheckDisposed ClassInfo ClassName ClassNameIs ClassParent ClassType CleanupInstance DefaultHandler DefaultHandlerStr Dispatch DispatchStr Disposed DisposeOf Equals FieldAddress Free FreeInstance GetDisposed GetHashCode GetInterface GetInterfaceByStr GetInterfaceEntry GetInterfaceEntryByStr GetInterfaceTable GetInterfaceWeak GetLastCastErrorInfo InheritsFrom InitInstance InstanceSize MethodAddress MethodName newinstance QualifiedClassName StringMessageTable SystemHasExtendedRTTI UnitName

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.