Welcome to the new DelphiDabbler Code Library Documentation.

This is a new site that's currently running on alpha code. There are going to be bugs. If you discover any, please report them on the site's issues page (GitHub account required). Thanks.

Warning: Many URLs are going to change. Refer to the README file to discover which library project's documentation has been completed.

TPJRegWdwState

Project: Window State Components.

Unit: PJWdwState.

Applies to: ~>5.0

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.

NOTE: It is strongly recommended that this component is not used in 32 bit applications compiled with Delphi 5 and earlier that are to be run on 64 bit Windows operating systems. This is because the TRegistry class used by TPJRegWdwState does not support the permissions needed to access the 64 bit registry view.

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 [~>5.1] and OnPuttingRegData [~>5.1] 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 (or RootKeyEx [~>5.6]) and SubKey properties respectively. Alternatively the OnGetRegData (or OnGetRegDataEx** [~>5.6]) 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 Specifies the HKEY value of the registry root key under which the window’s size, position and state information is stored.
RootKeyEx [~>5.6] Similar to RootKey except that instead of taking an HKEY value it takes a value from the TPJRegRootKey [~>5.6] enumeration.
SubKey Determines the registry sub key under which the window’s size, position and state information is stored.

Events

Event Description
OnAfterWindowRestored [~>5.4] Event triggered after window has been restored and its state set.
OnAfterWindowSized [~>5.4] 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. The registry root key is specified by it HKEY value.
OnGetRegDataEx [~>5.6] Similar to OnGetRegData except that the root key is specified by a value from the TPJRegRootKey [~>5.6] enumeration.
OnGettingRegData [~>5.1] Event that allows user to read additional registry data when the component reads window state information.
OnPuttingRegData [~>5.1] 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.