TPJWdwState & TPJRegWdwState Components


Contents


Description

The file wdwstate.pas includes two components - TPJWdwState and TPJRegWdwState, along with a property editor (TPJHKEYPropEditor) for editing the registry root key property of TPJRegWindowState.

The components can save the state (minimised, maximised or normal) of a form window, along with its size and position. TPJWdwState saves the information to a ini file while TPJRegWdwState saves to the registry. The components can also read information back and restore the saved window settings. This means the components can be used to restore a window to the condition it was in during some previous execution, just by calling a couple of methods.

With TPJWdwState you can specify the name of the ini file, or let the component choose one. You can also decide the name of the section within the ini file that will be used. Again the component can provide a suitable default section name.

Similarly with TPJRegWdwState you can specify the registry root and sub-keys under which the information is saved. Again suitable default values are used if no keys are specified.

Also included in the wdwstate.pas unit is the component TPJCustomWdwState. This component is an abstract base class for both TPJWdwState and TPJRegWdwState.


Compatibility

The components and property editor have been tested with Delphi 2, 3 and 4. It is likely that they will work with Delphi 5, but this has not been tested. They are not compatible with Delphi 1.

An older version of TPJWdwState that is compatible with Delphi 1 is available from my website.


Installation

In these instructions $(DELPHI) is to be taken to represent the path where the appropriate version of Delphi was installed. For example, if you have Delphi 2 installed on the default installation path then $(DELPHI) is equivalent to C:\Program Files\Borland\Delphi 2.0.

Installation with Delphi 2

  1. Unzip the file wdwstate.zip into a folder, preserving the directory structure.
  2. Copy wdwstate.pas, wdwstate.dcr and PJHKEYPropEdit.pas to the folder from where you wish to install the components into the Delphi Component Palette. This will probably be an existing folder where you keep library components - say the default $(DELPHI)\lib sub-folder.
  3. Copy the help files wdwstate.hlp and wdwstatr.hlp and the keyword files wdwstate.kwf and wdwstatr.kwf into the $(DELPHI)\help folder.
  4. Merge the help keyword files by running helpinst.exe from the $(DELPHI)\help\tools folder. When helpinst.exe is running open the delphi.hdx file and add wdwstate.kwf and wdwstatr.kwf and click on the Save button.
  5. Start Delphi. Select the Component | Install menu option. Click the Add button, then the Browse button and navigate to the wdwstate.pas file in the folder where you placed it. If you wish to also add the property editor then repeat the process with PJHKEYPropEdit.pas. Click OK to recompile the component library.
  6. You can now delete wdwstate.pas and PJHKEYPropEdit.pas from the place where you copied them if you wish. The components will appear on a palette called PJ Stuff. You can move the components to a different palette as required, or hack the source code (before installing the components) by finding the Register procedure at the end of wdwstate.pas and changing the string 'PJ stuff' to the name of the required palette.

Installation with Delphi 3 & Delphi 4

Note that although the provided help files give information about using the components they cannot be linked into the Delphi 3 or Delphi 4 environments at present.

  1. Unzip the file wdwstate.zip into a folder, preserving the directory structure.
  2. Copy wdwstate.pas, wdwstate.dcr and PJHKEYPropEdit.pas to the folder from where you wish to install the component into the Delphi Component Palette. This will probably be a sub-folder of the $(DELPHI)\lib folder.
  3. Install the components and property editor into the palette by chosing the Component | Install Component menu option. The following instructions assume you are installing into the default "users components" package:
  4. You can now delete wdwstate.pas and PJHKEYPropEdit.pas from the place where you copied them if you wish. The components will appear on a palette called PJ Stuff. You can move the components to a different palette as required, or hack the source code (before installing the components) by finding the Register procedure at the end of wdwstate.pas and changing the string 'PJ stuff' to the name of the required palette.


Known Issues

Fixed


Update History

Release 1.0 of 15/08/1999
WdwState v1.0 of 15/08/1999

Release 2.0 of 19/10/1999
WdwState v2.0 of 18/10/1999

Release 2.1 of 29/11/1999
WdwState v2.1 of 29/11/1999

Release 3.0 of 05/04/2000
WdwState v3.0 of 05/04/2000

Release 3.1 of 29/04/2000
WdwState v3.1 of 29/04/2000

Release 3.1.1 of 08/10/2000
WdwState v3.1 of 29/04/2000
PJHKeyPropEdit v1.0.1 of 08/10/2000


Credits

Thanks are due to Stefan Winter for providing some of the code of version 2.2 and for adding a prototype version of the AutoSaveRestore property.


License & Disclaimer

The source code and help files for these components can be freely distributed on a not-for-profit basis providing that:

  1. the source code is not altered.
  2. this file is distributed with it unchanged

By not-for-profit I mean that you may recover out of pocket expenses incurred in distributing the code, but should not make a profit from this.

If you discover any bugs in this implementation, or if you have any update suggestions, please contact me on peter.johnson@openlink.org.

Please do modify the code for you own use. I'd like to see any changes you make - I could incorporate them into future versions. Please notify me of changes on at the above e-mail address.

This software is provided as is - no warranty is given as to its suitability for any purposes to which you may wish to put it.


About the Author

I'm Peter Johnson - a hobbyist programmer living in Ceredigion in West Wales, UK. I write mainly in Delphi, but occasionally dabble in C, C++ and Java. My programs are available for download on my web-site: http://www.pjsoft.contactbox.co.uk/.

I can be contacted by e-mail on peter.johnson@openlink.org.