

RhcRegComp V1.0


RhcRegComp is a component that allows the state of components on a form, and the size and position of the form itself to be saved to the Registry or an IniFile. This can then be  loaded again either automatically when the form is recreated, or under program control. You can select which components are to be saved using the integral component editor. One call to the Save method is all the coding that is needed to use this component.

The following standard Delphi components are supported:

* TCustomForm (TForm in Delphi 2) - The Position and size of the form are saved.
* TCustomEdit - The text property is saved.
* TMemo - The text contents are saved.
* TCheckBox - The checked property is saved.
* TRadioButton - The checked property is saved.
* TRadioGroup - The item selected is saved.
* TCustomPanel - The width and/or height is saved depending on the Align property. This is used to allow the position of TSplitter controls to be saved.
* TCustomGrid - The widths and heights of the cells are saved.
* TCustomDBGrid - The order and widths of the columns are saved (only the widths on Delphi 2, or to IniFiles).
* TCheckListBox - The checked state of the boxes is saved.
* TUpDown - The position property is saved.
* TDateTimePicker - The date and time are saved.

The custom versions of the components are used wherever possible, so as to allow RhcRegComp to work with any components derived from them. Purchasing the source code allows components to be easily derived from RhcRegComp providing support for saving other properties or components not implemented in the base component.


Installation

Delphi 3

The Delphi 3 version of the code is supplied as two packages: RhcRegCompReg.dpl which is the version you should install and RhcRegComp.dpl which is the run-time package without the component editor.

To install:
* Unzip the files to a temporary directory. 
* Copy the files from the Delphi3 directory to wherever you put your package files (c:\program files\borland\delphi3\lib will do if you don't have anywhere else). You must ensure that the directory is also in your Windows PATH variable, in AUTOEXEC.BAT otherwise Delphi will not find RhcRegComp when it loads up.
* Run Delphi 3 and select Install Packages from the Component menu.
* Install RhcRegCompReg.dpl (or RhcRegCompReg.dpk if you have the source).
* The component should be available in the RHC tab of the component palette.


Delphi 2

* Unzip the files to a temporary directory. 
* Copy the files from the Delphi2 directory to wherever you put your custom components (c:\program files\borland\delphi2.0\lib will do if you don't have anywhere else). 
* Run Delphi 2 and select Install... from the Component menu.
* Install RhcRCReg.dcu (RhcRCReg.PAS if you have the source)
* The component should be available in the RHC tab of the component palette.


Usage

Just drop the component on a form, set the RegName and Section properties. Then double click on it to open the component editor and select which components you wish to save the state of - the form is added to the list automatically. Finally add a call to the RhcRegComp's Save method, the OnClose handler for the form is a good place. 

Check out the demo program to see the component in use.


Design interface

Properties

AutoLoad
Load the settings for the associated components automatically on start up. If this is False, you will need to call the Load method manually.

Components
A list of component names to load/save the settings for. The component editor allows this to be set easily at design time, but otherwise it is just a TStringList.

Filename
The filename to use if this is using IniFiles. Set RegType and FilePath.

FilePath
The path prepended to the Filename if using IniFiles. This can be:
fpNone:         		Use the Filename setting verbatim
fpExePath:      		Use the path of the Exe file
fpWindowsPath:  		Use the Windows directory
fpTempPath:     		Use the current temp directory

RegName
The name of the Registry Key to use if using the registry (see RegType and Section). Normally this is "SOFTWARE\YourName\YourProduct".

RegType
The place to store the component info. Either: rtRegistry or rtIniFile. 
I'm considering implementing filestreams also...

Section
The subsection to use. If RegType is rtIniFile this is the Section of the ini file to use. If it is rtRegistry then the name is appended to RegName.

Events

OnLoad
Called when the Load method is called, after the component state info has been loaded. Use this to save other state information.

OnSave
Called when the Save method is called, after the component state info has been saved. use this to load other state information.

Methods

Save
Save the state of all the components in the Components list. This is the only method you need to use under normal circumstances. Also calls the OnSave handler if assigned.

Load
Load the state for all the components in the Components list.
Also calls the OnLoad handler if assigned.

WriteString(name, value: string);
ReadString(name, default: string): string;
WriteInteger(name: string; value: Integer);
ReadInteger(name: string; default: Integer): Integer;
WriteBool(name: string; value: Boolean);
ReadBool(name: string; default: Boolean): Boolean;
EraseSection;
ReadBinaryData(Name: string; var Buffer; BufSize: Integer): Integer;
WriteBinaryData(Name: string; var Buffer; BufSize: Integer);
Various helper routines to access the registry/inifile. Use these in applications or when deriving from TRhcRegComp to support other components. ReadBinaryData/WriteBinaryData only work if RegType is rtRegistry.

AllowComponent(AComponent: TComponent): Boolean
Check if a component type is supported. Override this to add support for other components.

LoadComponent(AComponent: TComponent)
Load a component state. Override this to support other components. Only accessable in the shareware version.

SaveComponent(AComponent: TComponent)
Save a component state. Override this to support other components.

UpdateList
Used by the component editor to ensure the component list has the current names of all the components.

Source code

You may purchase the entire source code for this component, including the component editor using one of the following methods:

* CompuServe

If you are a compuserve member you can order it using their shareware registration service:

GO SWREG - Registration Id is 17212, cost is $14.95


* Direct from the author

Send Cheque for 9.00 UK Pounds payable to "Robert Harvey Consulting" to this address:

RHC
Dogdale
Church Street
Merriott
Somerset
TA16 5PT
United Kingdom

UK currency only I'm afraid.  Delivery is by EMAIL only, so make sure you include your email address!


* ShareIt

Order online at a cost of $14.95 on the Internet at http://www.shareit.com/programs/101678.htm

Alternatively, you can go to http://www.shareit.com and enter the program number there: 101678.

You may also order by Phone/Fax/Email directly from ShareIt using the order form below:


Registration form for RhcRegComp


Program No.: 101678

Last name: ___________________________________

First name: ____________________________________

Company: ____________________________________

Street and #: ______________________________________

City, State, postal code: ________________________________

Country: _______________________________________

Phone: _____________________________________

Fax: ________________________________________

E-Mail: ______________________________________


Deliver by email only


How would you like to pay the registration fee of $14.95:

credit card - wire transfer - EuroCheque - cash


Credit card information (if applicable)

Credit card: Visa - Eurocard/Mastercard - American Express - Diners Club

Card holder: ________________________________

Card No.: ___________________________________

Date of Expiration : ___________________________________



Date / Signature ___________________________


Disclaimer

Robert Harvey Consulting is not responsible for any damage to your data caused as a result of using this component. 

You may distribute any application that includes this component with no royalties. If you have purchased the source code to the component you may not distribute the source code, or sell a component based on this source code.

The RhcRegComp component is copyright by Robert Harvey Consulting and is protected by international law. We reserve all rights. 


For more information on this and other products see our web page at: 
http://www.findme.co.uk/delphi/

Or email:  
rhc@findme.co.uk



(c) Copyright 1998 Robert Harvey

