Resource Wizard v1.01
Copyright (c) 1997 Simon Goldstone
SIMON GOLDSTONE
email:
[email protected]
Description:
============
A Delphi 3.0 component which enables visual components to
be localized for different languages quickly and easily.
The component looks at every control on the form it is
placed upon. If the control's caption starts with a
special code and then an integer value, the integer
value is used to load a string from a resource file.
This string is then assigned to the caption.
For instance, suppose that a TLabel is placed upon a
form with the caption '*1234'. When the Resource Wizard
executes, it looks in the EXE's string resources for
string number 1234. If such a string exists, the caption
is assigned the string, otherwise it is left blank.
Standard Disclaimer
===================
USE THIS COMPONENT AT YOUR OWN RISK. IT'S AS SIMPLE AS
THAT. No warranty as to fitness for purpose is given or
implied. If you computer explodes as a direct or indirect
consequence of the use or miuse of this component - tough!
Cost
====
This software is HonestyWare Shareware.
If you belong to an academic institution (student, lecturer, etc.)
This component is free to use (you're welcome) so long as you
do not profit from or charge for any software which uses this
component. This component must only be used for research purposes.
If you are a commercial enterprise or you intend to profit from
or charge for software which uses this component, then the
charge for royalty-free lifetime use of this component is
an enormous # 5.00 (FIVE BRITISH POUNDS STIRLING).
For payment details, contact the author:
[email protected].
Please do not rip me off. For the sake of #5.00, be nice.
Source code is available for an extra # 10.00.
Installation
============
If you have any problems installing the component, contact me
and I'll try to help you:
[email protected]
This version is for Delphi 3.0 ONLY. Other Delphi versions may
be supported if there is a demand.
To install:
1. Put the .DCU and .DCR file in a directory of your choice
(where you keep all your custom components)
2. In Delphi, choose Component|Install Component...
3. In the Dialog Box, choose either tab.
4. If you chose to install into an existing package, browse for
the .DCU file, make sure the search path is set up and then
browse for the package file you want to add the component to.
5. If you chose to install into a new package, follow the steps above
but type a new package name in the field.
Consult the Delphi help for more info on installing components if
you get stuck.
6. The component is called TResourceWizard and will be located
in the component pallete under the "SiGol" page.
Usage:
======
1. Place a TResourceWizard component on the form. Place some
visual controls on the form as desired. Set the controls'
caption property to '*' followed by an integer (no spaces).
Note that you can do the same for the form's caption too.
2. If you want the Resource Wizard to automatically load
resources from the EXE's resource table when the wizard
executes, set the AutoLoad property to true. If you want
to assign the strings yourself at runtime when the component
executes, set the AutoLoad property to false.
3. If the AutoLoad property is true, create string resource
files as necessary and compile them using BRCC.EXE (see below).
Then link the compiled resource file into the form's unit using
the {$R XXX.RES} compiler directive.
4. If the AutoLoad property is false, create a
TResourceChangeEvent. In this event implementation, write the code
which manually sets the caption property. Note this event will
ONLY fire if the AutoLoad property is set to false.
5. In the form's OnCreate event, call the wizard's Execute method:
...
begin
ResourceWizard1.Execute;
end;
...
6. Run the project.
Example:
========
An example project and string resource file is included in the
original ZIP file.
Creating String Table Resource files
====================================
1. Create a new text file in the editor. Give this file any name
but give it the extension .RC (convention).
The format of the file is as follows:
STRINGTABLE DISCARDABLE
{
INT STRING
INT STRING
... ......
... ......
INT STRING
}
Where "INT" is an integer identifier and "STRING" is the
string you want it to represent.
2. Once you have creates the resource file, save it and then
run the BRCC.EXE program (usually located in the Delphi/Bin
directory.
BRCC.EXE name.rc
This will compile the resource script and produce a resource
file (SAMENAME.RES).
3. You must then link the resource file into your unit:
{$R SAMENAME.RES}
4. That's it!
AutoLoading
===========
If AutoLoad is set to true, the Resource Wizard looks in the
resources for the EXE. If AutoLoad is false, the Wizard uses
the OnResourceChange event which you should define.
If you do not define an OnResourceChange event and AutoLoad
is set to false, the captions of all controls on the form
will be set to blank.
OnResourceChange
================
The format of the OnResourceChange event is as follows:
type
TResourceChangeEvent = procedure ( Sender: TObject; Comp: TComponent;
Ident: Integer; var Caption: string)
of object;
Sender is the ResourceWizard that called the event. Comp is the control
that needs localizing. Ident is the integer identifier for the resource string
to load. Set the caption property as appropriate.
Simple example:
TMyForm.ResWiz1ResourceChange ( Sender: TObject; Comp: TComponent;
Ident: Integer; var Caption: string);
begin
case Ident of
1001: Caption := '&OK';
1002: Caption := '&Cancel';
1003: Caption := '&Help';
end;
end;
TROUBLESHOOTING
===============
Don't forget to use the Execute method !
BUGS / PROBLEMS
===============
If you encounter any problems or bugs using this component, I'd like to
hear from you. Please contact me on
[email protected]. I can't promise
to fix the problem, but I'll try.
History
=======
28-Aug-97 Release 1.1.
28-Aug-97 Added form caption handling
28-Aug-97 Release 1.0.
27-Aug-97 Beta version and testing
26-Aug-97 Added AutoLoading and OnResourceChange event
25-Aug-97 Alpha version