TPJWdwState & TPJRegWdwState Components


Contents


Description

The file wdwstate.pas includes two components - TPJWdwState and TPJRegWdwState. These 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.

TPJRegWdwState is not available with Delphi 1 since it depends on TRegistry which is not supported by Delphi 1. When installing the wdwstate.pas file under Delphi 1 the TPJRegWdwState component is not compiled.

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


Compatibility

TPJWdwState has been tested with Delphi 1, 2, 3 and 4 and TPJRegWdwState has been tested with Delphi 2, 3 and 4. They may work correctly with Delphi 5 but have not been tested.


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 1

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

Installation with Delphi 2

  1. Unzip the file wdwstate.zip into a folder, preserving the directory structure.
  2. Copy the file wdwstate.pas to the folder from where you wish to install it 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 wdwstate.dcr from the 32 sub-folder into the same place that you copied wdwstate.pas.
  4. Copy the help files wdwstate.hlp and wdwstatr.hlp and the keyword files wdwstate.kwf and wdwstatr.kwf into the $(DELPHI)\help folder.
  5. 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.
  6. Start Delphi. Select the Options | Install Components menu option. Click the Add button, then the Browse button and navigate to the wdwstate.pas file in the folder where you placed it. Click OK to recompile the component library.
  7. You can now delete wdwstate.pas from the place where you copied it 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 the code 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 the file wdwstate.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. Copy wdwstate.dcr from the 32 sub-folder into the same place that you copied wdwstate.pas.
  4. Install the components into the palette by chosing the Component | Install Component menu option. The following instructions assume you are installing into the default "users components" package:
  5. You can now delete wdwstate.pas from the place where you copied it if you wish. The component will appear on a palette called PJ Stuff. You can move the component to a different palette as required, or hack the source code (before installing the components) by finding the Register procedure at the end of the code and changing the string 'PJ stuff' to the name of the required palette.


Known Issues


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


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 [email protected].

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://homepages.tesco.net/~p.d.johnson/

I can be contacted by e-mail on [email protected].