TPJRegWdwState
Project: Window State Components.
Unit: PJWdwState.
This non-visual component enables the size, position and state of the form on which it is placed to be saved to and read from the registry.
The Save method saves the window information to the registry and the Restore method reads information in and sets the owning form window's size, position and state.
The component's AutoSaveRestore property governs whether window sizes, positions and states are automatically restored on opening and saved on closing or whether the user must explicitly call the Save and Restore methods.
The Options property and the OnReadWdwState event can be used to customise how the stored data is interpreted and whether the window's saved state or size should be used or ignored.
Application defined data can be read from and written to the registry by handling the OnGettingRegData and OnPuttingRegData events that are triggered when the component reads and writes its data.
The root and sub key to be used in the registry are specified using the RootKey and SubKey properties respectively. Alternatively the OnGetRegData event can be handled and used to set the root key and sub key to use.
It is only possible to have one instance of a TPJRegWdwState component on any one form. Neither can a TPJRegWdwState component be dropped onto a form that already contains either a TPJWdwState or a TPJUserWdwState component.
TPJRegWdwState exposes the following methods, properties and events, some of which are inherited unchanged from TPJCustomWdwState.
Methods
| Method | Description |
| Create | Class constructor that permits only one instance of the component to be placed on a form. |
| CreateStandAlone | Class constructor for use when creating components at run time. |
| ReadWdwState | Overridden method that reads a window's size, position and state from the registry. |
| Restore | Restores the size, position and state of a window from the registry. |
| Save | Saves the size, position and state of the window to the registry. |
| SaveWdwState | Overridden method that writes a window's size, position and state to the registry. |
Properties
| Property | Description |
| AutoSaveRestore | Determines whether the window's size, position and state is automatically restored on creation and stored on destruction. |
| IgnoreState | Determines whether the window's saved state (maximised, normal or minimised) is applied on restoration. This property is deprecated - use the Options property instead. |
| MinimizeDelay | Sets the delay between displaying a normalised form on screen and minimising it if required. |
| Options | Determines how the component interprets the window display data read from storage. |
| RootKey | Determines the registry root key under which the window's size, position and state information is stored. |
| SubKey | Determines the registry sub key under which the window's size, position and state information is stored. |
Events
| Event | Description |
| OnAfterWindowRestored | Event triggered after window has been restored and its state set. |
| OnAfterWindowSized | Event triggered after the window is sized but before it is physically restored. |
| OnGetRegData | Event that allows user to change the registry key where window information is stored. |
| OnGettingRegData | Event that allows user to read additional registry data when the component reads window state information. |
| OnPuttingRegData | Event that allows user to write additional registry data when the component writes window state information. |
| OnReadWdwState | Event that allows user to change the window data read from storage before the window is displayed. TPJRegWdwState publishes this inherited protected event. |