home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 14
/
CD_ASCQ_14_0694.iso
/
news
/
4547
/
pgr122
/
ptg_user.doc
< prev
next >
Wrap
Text File
|
1994-02-16
|
49KB
|
1,561 lines
▀▀▀▀▀ ▀ ▀▀▀▀▀
▀▀ ▀▀ ▀▄ ▀▀ ▀▀ ▀ ▀
▀▀▀▀▀▀ ▄▀ ▀▀▀ ▀▀▀▀ ▀▄▄▀ ▀ ▀ ▀
▀▀ ▀ ▀▀ ▀▀ ▀ ▀ ▀▀ 1.20
▀▀ ▀▀ ▀▀▀▀▀ ▀▀ ▀ ▀
(c) Copyright 1991, 1993 by Nederware, a dutch software company
User's Guide
written by Berend de Boer
DISCLAIMER
NEDERWARE PROVIDES THE SHAREWARE VERSION OF PTGEN "AS IS" AND
WITHOUT ANY WARRANTY. TO THE EXTENT PERMITTED UNDER APPLICABLE
LAW, NEDERWARE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO, ANY IMPLIED WARRANTY OF MERCHAN-
TABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SPECIFICALLY,
NEDERWARE MAKES NO REPRESENTATION OR WARRANTY THAT THE SOFTWARE
IS FIT FOR ANY PARTICULAR PURPOSE.
NEDERWARE SHALL NOT BE LIABLE FOR ANY DAMAGES RESULTING FROM THE
USE OF THIS SOFTWARE, INCLUDING BUT NOT LIMITED TO, LOSS OF
PROFIT, DATA OR USE OF THE SOFTWARE, OR SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES OR OTHER SIMILAR CLAIMS, EVEN IF NEDERWARE
HAS BEEN SPECIFICALLY ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
PtGen user manual - page i
TABLE OF CONTENTS
LICENSE . . . . . . . . . . . . . . . . . . . . . . . . . . . iii
INTRODUCTION . . . . . . . . . . . . . . . . . . . . . . . . 1
Assumptions . . . . . . . . . . . . . . . . . . . . . . 1
About PtGen . . . . . . . . . . . . . . . . . . . . . . 1
Features . . . . . . . . . . . . . . . . . . . . . . . . 1
TVTool . . . . . . . . . . . . . . . . . . . . . . . . . 1
Acknowledgements . . . . . . . . . . . . . . . . . . . . 2
INSTALLATION . . . . . . . . . . . . . . . . . . . . . . . . 3
The READ.ME file . . . . . . . . . . . . . . . . . . . . 3
Installation on harddisk . . . . . . . . . . . . . . . . 4
Environment variables . . . . . . . . . . . . . . . . . 4
Installation under Tools menu of Borland IDE . . . . . . 4
Needed units . . . . . . . . . . . . . . . . . . . . . . 4
PtGen DEVELOPMENT-CYCLE . . . . . . . . . . . . . . . . . . . 5
PtGen development-cycle . . . . . . . . . . . . . . . . 5
Ptgen single dialog box creating mode . . . . . . . . . 5
THE FILES CREATED BY PtGen . . . . . . . . . . . . . . . . . 7
The Source File . . . . . . . . . . . . . . . . . . . . 7
DEFINES.DEF . . . . . . . . . . . . . . . . . . . . . . 7
STRRESFS.TVR . . . . . . . . . . . . . . . . . . . . . . 7
STRINGS.TVR . . . . . . . . . . . . . . . . . . . . . . 8
STRINGS.INC . . . . . . . . . . . . . . . . . . . . . . 8
GENERAL OPERATION PRINCIPLES . . . . . . . . . . . . . . . . 9
Mouse operation . . . . . . . . . . . . . . . . . . . . 9
Keyboard operation . . . . . . . . . . . . . . . . . . . 9
SAMPLE APPS . . . . . . . . . . . . . . . . . . . . . . . . . 10
Creating a menubar and a statusline . . . . . . . . . . 10
Creating a dialog box . . . . . . . . . . . . . . . . . 14
CREATING AN EXECUTABLE . . . . . . . . . . . . . . . . . . . 17
A simple main . . . . . . . . . . . . . . . . . . . . . 17
A more advanced main . . . . . . . . . . . . . . . . . . 17
MORE ADVANCED TOPICS . . . . . . . . . . . . . . . . . . . . 19
Using string resource files . . . . . . . . . . . . . . 19
Adding units . . . . . . . . . . . . . . . . . . . . . . 19
Appendix A: Command line options . . . . . . . . . . . . . . 20
Appendix B: Environment variables . . . . . . . . . . . . . . 21
INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
PtGen user manual - page ii
LICENSE
Copyright 1991, 1993 by Nederware. All rights reserved.
COMMERCIAL DISTRIBUTION PROHIBITED WITHOUT WRITTEN CONSENT FROM
THE AUTHOR.
This version of PtGen is NOT public domain or free software, but
is being distributed as "shareware" for EVALUATION PURPOSES ONLY.
1a) You may copy and distribute copies of the PtGen source,
documentation, and executable code as you receive it, in any
medium, provided that you conspicuously and appropriately
publish on each copy a valid copyright notice "Copyright
1992 by Nederware"; keep intact the notices on all files
that refer to this License Agreement and to the absence of
any warranty; PROVIDE UNMODIFIED COPIES OF THE DOCUMENTATION
AS PROVIDED WITH THE PROGRAM; and give any other recipients
of the PtGen program a copy of this License Agreement along
with the program. You may charge a distribution fee for the
physical act of transferring a copy, but no more than is
necessary to recover your actual costs incurred in the
transfer. Under no circumstances is PtGen to be distributed
in such a way as to be construed as "value added" in a sales
transaction, such as, but not limited to, software bundled
with any other program without the prior written consent of
the author.
1b) Archive sites which are reachable by anonymous ftp is given
explicit consent to include PtGen on any media they think is
appropriate to distribute their collection.
2) You may use PtGen for a 30-day evaluation period on a
private, non-commercial basis, for the express purpose of
determining whether PtGen is suitable for your needs. At the
end of this 30-day evaluation period, you must either
purchase a license from Nederware for continued use of
PtGen, or discontinue using PtGen. See REGISTRATION.FRM for
details about purchasing a license.
3) As a user with license you are entitled to FREE updates
until the next major version. Versions can be differentiated
by their version number. The version number of your copy of
PtGen is listed in the about dialog box of PtGen.
A next major version differs from the previous major version
by changing of the number before the point in the version
number. Say you have version 1.4. If you want to use PtGen
2.1 you have to buy a new license. Licensed users get 50%
reduction in the price of the major version they want to
use.
FREE updates is FREE of extra cost outside shipping and
handling, usually not more than $10.00. If you have
CompuServe access it is possible to upload new software to
you using CompuServe's binary file transfer function. The
PtGen user manual - page iii
total cost of this process is for the user. The cost of this
is estimated to be about $6.00.
4) If you use this software for private, personal, non-
commercial means only then you may purchase this product at
a chepar rate. Non-commercial is: you're not using this
software for any purpose that is linked with commercial or
non-personal leisure activities of any kind. Commercial or
non-personal leisure activities include activities related
to any of your jobs wherefore you receive money.
Contact the author for details.
5) If this software is used for non-profit organizations, it is
possible in some cases to purchase a license without actual
cost. In such a case that organization needs a prior written
consent of the author which can be given or not given. There
can be no correspondence if this consent is not given for
the organization which asked it. If this consent is not
given, that organization should consider this software as
shareware and the normal license for this software applies.
PtGen user manual - page iv
INTRODUCTION
Assumptions
It's assumed that you have Turbo Pascal 7.0 installed on your
system. Further, knowledge about the object-oriented paradigm is
necessary as well as about Turbo Vision. No attempt will be made
to explain any of these items.
About PtGen
This tool is intended for Turbo Pascal programmers who wish to
enhance their productivity by rapidly building Turbo Vision
screens. This tool outputs source code and is capable of reading
that source code for further editing. PtGen comes in a real mode
and in a protected mode version. This manual applies to both
varieties.
Features
* creates complete applications or just standalone dialog
boxes
* quick interactive menubar building
* quick interactive statusline building
* quick interactive dialog box building
* full helptext support for statusline help as well as for
helpfiles (.HLP)
* build-in tutorial, covering creating of statuslines,
menubars and dialog boxes
* supports TVTool 2.0 (see below for section TVTool)
TVTool
PtGen supports TVTool 2.0. TVTool is a TurboVision tool written
by Richard Hansen who can be reached at:
CompuServe: 70242,3367
email: 70242.3367@compuserve.com
fidonet: 1:282/115
PtGen user manual - page 1
The TV Tool Box package was created to fill a few holes in
Turbo Vision for Turbo Pascal. TV Tool Box includes formatted
data entry with input masks, scrolling data entry dialogs, data
entry field locking, check mark menus, enhancements to
TApplication, some handy string routines, scrolling dialog boxes,
3D controls, virtual list boxes, spin bars, sliders and more.
PtGen currently supports all 3D controls of TVTool. Basic support
for the TbxEditLine (including mask definition) is also provided.
Planned enhancements include supporting all input mask inputlines
and supporting the scrolling dialog box.
Registered users of PtGen receive a 25% reduction on their TV
Tool Box package, just as registered users of TVTool receive a
25% reduction on their PtGen package.
The shareware version of TVTool is shipped with the registered
version of TVTool, just as the shareware version of PtGen is
shipped with every registered version of TVTool.
To receive your 25% registration discount YOU MUST INCLUDE your
PtGen registration number on your TV Tool Box order form.
THE SPECIAL 25% DISCOUNT IS ONLY AVAILABLE ON ORDERS MADE
DIRECTLY TO RICHARD HANSEN.
Acknowledgements
I would like to thank alpha tester Tom Kooij who provided me with
valuable suggestions about the PtGen user interface.
I would also express my thanks to the following people who
contrinbuted much to PtGen's operation: Hans van der Veeke and
David MiddleBrooks.
Also I wish to thank the betatesters Frank van der Ham and
Christian Haarmeijer who pointed out some inconveniences and
detected some errors.
PtGen user manual - page 2
INSTALLATION
The READ.ME file
Before installing PtGen, you should review the contents of the
READ.ME file on your PtGen distribution diskette. This file
contains important information (usage information, new features,
changes, known bugs, etc.) that became available after this
manual was printed. You should carefully review the READ.ME file
before using PtGen.
The READ.ME file also contains a complete list of the files
included on the distribution diskette. A partial list is included
here:
PTGEN.EXE The ProtoType Generator.
PTGEN.OVR The PtGen overlay file (for realmode version
only).
PTGHELP.HLP Help file.
PTG_USER.DOC This manual.
PTG_REF.DOC The reference manual.
CHANGES.DOC Overview of latest changes and additions.
READ.ME Latest information and complete list of files in
this distribution.
TUTORIAL.* Texts for the build-in tutorials.
REGISTER.FRM Registration form.
PREAPP.PAS Definition of the application object from which
the PtGen created application object is derived. A
copy of this file is needed for every application.
PREAPP.INC Identifier include file for PREAPP.PAS. Use
PREAPP.INC to change the string resource file
DEFAULT.TVR, ENGLISH.TVR and DUTCH.TVR
DEFAULT.TVR Default language strings for all provided units.
DUTCH.TVR Dutch resource strings for all provided units.
ENGLISH.TVR English resource strings for all provided units.
BBDLG.PAS TVision dialog boxes and views, see the reference
manual or online help for details.
BBFILE.PAS File I/O primitives, see the reference manual or
online help for details.
BBSTRRES.PAS Resource string handling, see the reference manual
or the online help for details.
BBUTIL.PAS Primitives, see the reference manual or online
help for details.
BBVALIDATE Validators, overriding the ones provided in
VALIDATE.PAS. The validators in the Validate unit
gave an english error message. The validators in
this unit do not, but retreive a resource string
so you can internationalize your validation.
PTGEN.TPH Online help which you can include directly in your
Turbo Pascal IDE or Borland Pascal IDE. It covers
PtGen user manual - page 3
all supplied units like BBUTIL and BBSTRRES.
Installation on harddisk
PtGen is simple to install. But first make a backup copy of the
distribution diskette.
Create a directory if necessary to hold your copy of PtGen. You
can create any directory you like. Advised directory is "PTGEN".
Make sure this directory is in your path because because each
program developed with PtGen needs a seperate directory. You will
call PtGen from the directory of each application.
Environment variables
Optionally you can set the environment variable PTGEN in your
AUTOEXEC.BAT. All command line options of PtGen can be preset in
this environment variable. If you specify
SET PTGEN=/50
PtGen will always start in 80x50 video mode. Specified
commandline options will override the environment variable
settings. See Appendix A for all commandline options.
The environment variable PTGINPUT specifies the directory where
PtGen should search for standard files PtGen needs when you
create a new application. For example the standard string
resource files ENGLISH.TVR should reside in this directory. Most
of the time you simply set PTGINPUT to the directory where the
PtGen executable resides.
Installation under Tools menu of Borland IDE
You can install PtGen also in the Tools section of the Borland
IDE. Choose Options|Tools and press New. Specify under Title
~P~tGen, under Program path for example c:\ptgen, under Command
line $EDNAME $SAVE ALL. As a hotkey I suggest Shift-F9 but any
other key or no key is alright too of course.
Needed units
Make sure your compiler can find units from
bp/examples/dos/tvdemo and /bp/examples/dos/tvfm. You need
CALCULATORS.PAS, GADGETS.PAS, HELPFILE.PAS, VIEWTEXT.PAS, and
maybe more.
PtGen user manual - page 4
PtGen DEVELOPMENT-CYCLE
PtGen development-cycle
This section shows you how to work with PtGen. But first is the
underlying software development cycle discussed. PtGen is a
prototype generator, that means, that you should not expect that
PtGen can create complete applications for you. It will let you
build TurboVision screens very fast and very visually but that's
not the end. For example, when you create a dialog box a dummy
TListViewer is inserted. What you should do is to first to create
the dialog box including all buttons, helptexts, etc., than copy
the dialog box code PtGen has outputted, and past it into your
program.
You don't have to copy/past all dialog code though. Some dialog
boxes are complete by themselves. But as soon as you want a
custom view to be inserted you need this copy/past scheme. An
examples of a complete, compilable application can be found in
the chapter titled Creating an Executable and the accompanying
source files DEMOMENU.PAS and DEMOMAIN.PAS.
The steps followed when using PtGen are:
1. Create a separate directory for each application.
2. Copy PREAPP.PAS to this directory. PREAPP.PAS contains the
application object from which the application object PtGen
creates is derived.
3. Start PtGen in this directoryand build a menubar, a
statusline, dialog boxes and helptexts.
4. Save your work as a PtGen readable Pascal source file. PtGen
readable means that several PtGen directives are inserted in
the source file, but they won't affect compilation.
5. Create the main of your application. You probably want to
override the HandleEvent of the TApplcation object PtGen has
created in its source file.
You probably need to copy/paste some PtGen created code to
your source files if you want to change or add custom views.
6. Compile your program.
This development cycle will become clearer after you have worked
with PtGen and read the chapters Sample Apps and Creating an
Executable.
Ptgen single dialog box creating mode
For people not wanting to create a complete application but just
use PtGen's dialog box creating capabilities there is an option
Dialog|New. You don't have to follow the previous steps and you
can just create a single dialog box. After you close the dialog
PtGen user manual - page 5
box you can save the source code of the create dialog box to a
file. You can read this file with Dialog|Open.
PtGen user manual - page 6
THE FILES CREATED BY PtGen
In this section the files that PtGen creates are explored.
The Source File
As already said, PtGen creates normally, compilable Turbo Pascal
source code. PtGen can read that source code back if you want to
re-edit or change the created menubar, statuslines, dialog boxes
or helptexts.
The form of the source code is a unit which you can use in your
program. The main object defined in this unit is a descendent of
TPreApp, which is a descendent of TApplication. The Application
object PtGen creates does not descent directly from TApplication
in this way. The parent object is TPreApp, which is defined in
PREAPP.PAS This allows you to place common code for your objects
in PREAPP.PAS.
DEFINES.DEF
Besides this source code file, PtGen creates several other files.
The first file to mention is DEFINES.DEF. PREAPP.PAS is also used
to define the conditional code, code that the applications you
create may need. For example if you specified that you want to
create online help a special file with directives is created
which in turn enables certain parts in PREAPP.PAS to be compiled.
The file in which the directives are placed is called
DEFINES.DEF. This file is included with i $I into PREAPP.PAS.
Because the compilation of PREAPP.PAS is application dependent,
it is recommended that for every application you create, a
separate directory is created to which PREAPP.PAS (and
PREAPP.INC) are copied.
The possible conditional symbols that can be created in
DEFINES.DEF are:
- {$DEFINE Help} When you specified that you wanted to use the
Help Window Option (Note that the context-sensitive statusline
help can always be used.) If you enabled this option you can
create help windows, including cross-references, much like the
online Help of TP7.
- {$DEFINE Editors} if you specified that you wanted to make use
of the Editors unit in your program.
- {$DEFINE BufferedPrinter} if you specified that you wanted to
use the background printing unit.
STRRESFS.TVR
PtGen lets you use various string resources for your application.
If you have defined seperate string resources for one or for a
PtGen user manual - page 7
cluster of releated units, you can add such string resources to
your application. When writing the source file for your
application all string resource files and identifier files are
read and put in one file, called STRINGS.TVR (see below). PtGen
stores the filenames of all these string resource files and
identifier files in STRRESFS.TVR.
This file is only created if you have specified string resources
above the standard one (see STRINGS.TVR).
STRINGS.TVR
After you have specified which string resources to use, they
should be accumulated in one file. That file is called
STRINGS.TVR. All statusline helpstrings and all language
dependent strings (in ENGLISH.TVR, DUTCH.TVR or other) are saved
in STRINGS.TVR. If you specified other string resources in
STRRESFS.TVR they will be saved to STRINGS.TVR too.
The BBSTRRES unit gives you easy acces to strings stored in this
file.
STRINGS.INC
In STRINGS.INC all resource string identifiers are accumulated
for this application. STRINGS.INC should correspondent with
STRINGS.TVR
PtGen user manual - page 8
GENERAL OPERATION PRINCIPLES
In the following two sections general principles when working
with PtGen are covered.
Mouse operation
PtGen is designed to be very consistent. You will find the same
basic set of operations throughout PtGen. Learn them once, and
you know it for ever. First the basics for mouse users are
covered, than for keyboard users.
Left button Clicked on backgrounds pop-ups the local menu
Right button When the mouse is on an object/item, pressing the
right mouse button pops-up a menu with actions you
can apply to that object/item or it starts editing
the current object/item
Keyboard operation
Alt-F5 Pop-up local position menu for positioning the
current object
Alt-F10 Pop-up local menu
Ctrl-F7 Delete current object/item
Ctrl-F8 Edit current object/item
Ctrl-F9 Link other objects to your object
Ins Insert an item
Del Delete an item (same as Ctrl-F7)
OK, enough explanation. The next chapter will let you create some
sample applications.
PtGen user manual - page 9
SAMPLE APPS
We'll build three different sample applications. The first two
are covered by the build-in tutorial although the written version
has more explanation and references other and advanced features.
The first application lears you to create menus and a statusbar.
The next learns you to create dialog boxes.
Detailed information about the above mentioned subjects/ob-
jects(!) can be found in the reference manual.
For every application:
1. Create a separate directory
2. Copy PREAPP.PAS and PREAPP.INC from your PtGen directory to
this directory. The application object PtGen creates, is a
descendent of the application object defines in this file.
3. Start PtGen from this directory so all files created by
PtGen will be placed in this directory.
Creating a menubar and a statusline
To create a new application, just start up PtGen.
1. Select New from the File menu.
Now you're asked to specify some information about the new
application you're creating.
2. Fill in the application name, in our case SampleApp.
Your application will be saved in a source file you specify and
the name will be: TSampleApp. PtGen automatically adds a T or P
to the name of every object it creates, so don't specify T's or
P's.
PtGen supports helptext creating. To enable this option you have
to mark Help in the Options menu and you have to specify a
filename.
3. Enable the Help option
4. Specify as helpfile: sample.txt.
The other options are explained more fully in the reference
manual. We will not use this feature in our sample application.
5. Press Enter or click OK to close this dialog box.
You are now ready to edit your application.
6. Select Edit from the menubar or press Ctrl-F8 to edit your
application.
PtGen user manual - page 10
Next, you'll see an almost empty menubar and an empty statusline.
Let's add the familiar F1 and F10 to the statusline.
7. Popup the local menu by pressing Alt-F10 or, for mouse
users, press the left button.
A popup menu appears.
8. Choose Statusline.
Go to the StatusKeys listviewer by pressing Tab. Now press the
down arrow once (the lightbar should now be on kbF10).
And add your first item.
9. Press Ins or click on new.
A dialog box appears in which you can specify the same parameters
as the NewStatusKey function.
10. Enter after Text:
~F2~ Save
Enter after Keycode
kbF2
Enter after Command
cmSave
11. And press Enter or click OK to close this dialog box.
When you look at the statusline, you'll see that F1 has appeared.
Do the same for F10.
12. Press Ins, enter after Text
~F3~ Open
Enter after Keycode
kbF3
Enter after Command
cmOpen
And press Enter to close the dialog box.
And for Alt-X.
13. Press Ins.
Leave the Text inputline empty,
enter after Keycode
kbAltF3
After Command
cmClose
and press Enter to close the dialog box.
You see that in the Statusline dialog box entries are
differentiated by their keys. If no key is specified (kbNoKey),
the first part of the text is shown.
PtGen user manual - page 11
To close the statusline dialog box, press Enter again.
14. Press Enter to close the statusline dialog box.
OK, now the menubar.
15. Press Menu (F10).
You'll see that a lightbar appears on menu ≡, but when you look
at the statusline, you see that it hasn't changed. But in the IDE
of Turbo Pascal the statusline changed to
F1 Help │ System commands
It isn't there, but soon it will be. We have to add some helptext
to the ≡ menuitem.
16. Press Edit (Ctrl-F8).
The edit dialog box for a menu item appears. You can add all
options you could when handcoding menu's for Turbo Vision and
more. You can specify a statusline helptext and a normal helptext
which the user accesses by pressing F1.
REMARK A: helptexts for F1 will only be stored in a file when you
had set helpfile on and had specified a helpfile name in the
application edit dialog box, the one you where you specified the
application's name.
REMARK B: Only after TVHC has been run to compile a helpfile
(.HLP) from the saved text, will helpfiles be shown on the
screen.
Instead of running TVHC you could also select HelpText from the
Desktop Local menu. Next press the Compile button.
17. Add a helptext by entering
system commands
after help text and press Enter to close the dialog box.
You will now see that the statusline has changed and now shows
the desired text. For more information about the menuitem dialog
box, see the reference manual.
Adding a menuitem is equally simple. We will add a submenu, the
first part the File submenu as found in the Turbo IDE.
18. Move the lightbar on the symbol, the end symbol. Now press
Ins to insert a menuitem.
The menuitem dialog box will appear.
19. Enter after Name
PtGen user manual - page 12
~F~ile
20. Enter after Help text
File management commands (Open, New, Save, etc.)
Leave the other fields empty.
21. Select OK to close this dialog box.
The lightbar automatically moves right so you can quickly enter
more menuitems, but let's first edit the created menu. Because
you didn't specify a command, this will be a submenu.
22. Move the lightbar to File and press Enter.
An empty submenu will appear with only the Endmark symbol
present. You can add more menuitems by pressing Ins.
23. Add a new menuitem by pressing Ins. Enter after Name
~O~pen...
After Command
cmOpen
After Keycode
kbF3
After Param
F3
We will not use hcConstant in this example, so leave it empty.
See the reference manual for details and meaning of hcConstants.
Generally speaking: hcConstants are used to refer to helptexts
which you will use on more than one place your application. This
saves you typing time and promotes consistency.
24. Enter after Help text
Locate and open a file in an Edit window
25. Select the OK button to close the dialog box.
So, that's it for now. You learned how to create statuslines and
menubars.
26. Press Exit (Alt-X) to exit your created application.
You return now to PtGen.
27. Press Menu (F10) and select Save from the File menu. You
will be prompted for a filename. Enter
Sample
and select OK to save your application.
PtGen will now save your application in Pascal source code
format. It's a advised to look at the code PtGen's created to get
PtGen user manual - page 13
a feeling for what it does. This is not necessary, but I think
you will use PtGen frequently to quickly prototype a screen and
than copy code fragments to your application and edit it further
as already explained. See chapter DEMO for more information.
Creating a dialog box
We'll use the application you created in the previous example.
It's assumed that you are at the Dos prompt.
1. Type
ptgen sample
and press Enter.
PtGen will now load the code in SAMPLE.PAS.
2. Select Edit from the menubar or press Edit (Ctrl-F8) to edit
your application.
We will add an about dialog box to this sample application.
3. Press Menu (F10), position the lightbar on ≡ and press
Enter. Position the lightbar on the About menuitem.
We wish that as we select About from the System menu an about
dialog box pops up. We can do this by linking a dialog box to
this menuitem.
Take a look at the About menuitem by pressing Edit (Ctrl-F8). You
see that after Command is specified "cmAbout". Press Esc to close
this dialog box.
We now link a dialog box to this About menuitem, that means: any
time that the cmAbout command is encountered, this dialog box
will pop up.
You can link code by pressing Link (Ctrl-F9).
4. Press Link (Ctrl-F9). There is no mouse equivalent for this
operation.
A pop-up menu will appear from which you can choose between
Predefined code, or self-to-Defined code. Under the Predefined
option you will for example find a complete calculator. See the
Links chapter in the reference manual for more information about
Links and predefined objects.
A dialog box is code you interactively define.
5. Select Define and then select Dialog box.
First you have to specify some general information about this
dialog box. You can specify its name, its title and its helptext.
More information about the last item can be found in the
PtGen user manual - page 14
reference manual. We will only specify its Name and its Title.
6. Specify its Name as
AboutDlg
And enter after Title
About
and press Enter to close the Define a dialog box dialog box.
Now you see the dialog box with the Title you specified. You can
always edit the dialog box name and the Title by popping up the
local menu and selecting Settings.
At this moment you can resize/move the dialog box just by
pressing Resize (Ctrl-F5). Mouse users can do it their way
(clicking on the upper frame, or lower-right corner).
A dialog box is an object which can contain other objects. You
can pop-up a local menu with the objects you can place in this
dialog box by pressing Local Menu (Alt-F10). Mouse users can
place the mouse anywhere on the dialog box and press the Left
mousebutton to popup the local menu. Objects that mouse users
select from the local menu will be placed on the dialog box with
their upperleft corner at the current mouse position.
7. Since we are making an About dialog box, pop-up the local
menu and select Static Text.
You're prompted to specify the text.
8. Enter the following text just as it appears. So enter for ^C
first a "^" than a "C":
^CTurbo Pascal^M^M^CVersion 7.0
and select OK.
The ^C means center this text, ^M means go the next line.
You will see the text centered and a blank line between Turbo
Pascal and Version 7.0. If you are a keyboard users, you can move
and resize the text by pressing Local Move/Resize (Shift-F5). If
you are a mouse user you can do so by placing the mouse on this
view and pressing the right mousebutton, holding it down and
selecting Move or Resize from the popup menu.
9. Press Local Move/Resize (Shift-F5) to spread the whole text
from the left to the right of the dialog box.
If you are a mouse user you can do so placing the mouse on
the StaticText view and pressing the right mouse button.
Select first Move to move the view to the left edge. Then do
the same and select Resize to resize the right edge of the
StaticText view to the right edge of the dialog box.
PtGen user manual - page 15
You will now insert an OK button.
10. If you are a keyboard user: pop-up again the local menu by
pressing Local Menu (Alt-F10), select Predefined and then
select OK.
If you are a mouse user: place your mouse in the middle of
the second half part of the dialog box. Press the left mouse
button and hold it down. The local menu appears: select
Predefined, then select OK.
The OK buton will appear in the upperleft corner if you used the
keyboard equivalent, or in the place your mouse was before
pressing the left mousebutton.
You can now move or even resize the button.
There are some four actions you can do with the objects you place
on a dialog box. Keyboard users have to press the appropriate key
while mouse users can select the actions from the popup menu
which appears if you press the right mousebutton while your mouse
is on an object.
1) Move. Press Local Move/Resize (Shift-F5) if you are a
keyboard users.
2) Resize. Press Local Move/Resize.
3) Edit. Press Edit (Ctrl-F8). You can edit an object
parameters. For example you can edit the static text view to
add or change some text. All objects can be editted.
4) Delete. Press Delete (Ctrl-F7). Delete the object.
You can select an object with the common Tab/Shift-Tab keys or by
selecting them with the mouse.
We are now going to end the dialog box creating. There are many
more objects you can place on a dialog box as you saw when you
popped up the local menu. They are all listed in the Reference
Manual.
11. Press Enter to close this dialog box, then press Alt-X to
quit to PtGen.
You are back in PtGen and you can save the application you
created.
12. Press Alt-X to exit PtGen. A dialog box asks you if you want
to save your application. Just press Enter and your
application is saved before PtGen returns to the dos prompt.
PtGen did save your application in Turbo Pascal source code
format. It saved it as a unit. To turn the application you
created to an executable see the next chapter.
PtGen user manual - page 16
CREATING AN EXECUTABLE
The code PtGen saves is saved as a unit. As units can't be run,
you need to write a program. Sometimes this is very simple, most
of the times, your program contains the real flesh and PtGen
provides only the skin. Two examples are given: one very simple,
the most basic one. And one more complex and realistically.
A simple main
The most basic Main is the following program. Assumed is that you
saved your application in file SAMPLE.PAS and that you named your
application object SampleApp.
program Main;
uses Objects, {* contains RStringList *}
HelpFile, {* the helpfile unit from
bp/examples/dos/tvdemo
Sample, {* which contains the Application object *}
BBStrRes; {* PtGen resource string unit *}
var
TMyApp : TSampleApp;
begin
{* register helpfile *}
RegisterHelpFile;
{* initialize string resources *}
RegisterType(RStringList);
LoadStrings;
TMyApp.Init;
TMyApp.Run;
TMyApp.Done;
end.
The BBUtil, BBDlg, BBStrRes and BBFile units, the PREAPP.INC
include file as well as PREAPP.PAS (which should be in your
directory) should be available for the compiler as the unit that
PtGen creates needs them.
A more advanced main
program Main;
PtGen user manual - page 17
uses Objects, {* contains RStringList *}
Sample, {* which contains the Application object *}
BBStrRes, {* PtGen resource string unit *}
HelpFile,
BBError; {* the errorhandling unit *}
var
TMyApp : TSampleApp;
begin
{* initialize string resources *}
RegisterType(RStringList);
LoadStrings;
{* register helpfile *}
RegisterHelpFile;
{* initialize errorhandling unit *}
InstallExitHandler('MYAPP.LOG');
TMyApp.Init;
TMyApp.Run;
TMyApp.Done;
end.
The InstallExitHandler call will install an exit handler which
gives you a stack dump when your program is aborted. This stack
dump (and other information) is written to MYAPP.LOG.
See the file SQL2XPL.PAS for a complete working example. It
should be in the SAMPLE subdirectory or else in the SAMPLE.ARJ
file.
PtGen user manual - page 18
MORE ADVANCED TOPICS
This chapter discusses some more advanced topics in PtGen like
string resource files and adding units to the uses clause so you
can import your own views.
Using string resource files
Not yet provided.
See Chapter 7 of the Borland Pascal Resource Workshop User's
Guide which provides essentially the same information as should
be presented here. PtGen's string resource handling is modeled
after the Windows string resource handling.
Adding units
For some views (for example the inputline) you can press a code
button to change the pointer to the objecttype (for an inputline
this is PInputLine) or to add parameters.
In order to use your own views you can enhance the uses clause in
the implememtion section. To do so popup the Desktop Local Menu
by pressing Local Menu (Alt-F10) and choose Units. You can now
add, edit or delete unitnames.
The units will be added at the end of the uses clause.
PtGen user manual - page 19
Appendix A: Command line options
PtGen recognizes the following command line options:
filename - a PtGen generated pascal file (default extension
.PAS)
/h - this help screen
/BW - black and white palette for monochrome monitors
/50 - VGA 50 or EGA 43 lines
/NGM - don't use the graphics mouse
PtGen user manual - page 20
Appendix B: Environment variables
PtGen recognizes the following environment variables:
PTGEN - standard commandline options can be set in this
variable. The commandline always overrides the
specifications in the PTGEN variable
PTGINPUT - The directory where the files are located that PtGen
needs to create an application. Most of the time
this will be the directory where the executable
resides.
Such files are DEFAULT.TVR, ENGLISH.TVR, DUTCH.TVR,
PREAPP.INC and other.
You can specify more than one directory if you
seperate them by semicolons.
PtGen user manual - page 21
INDEX
Not yet provided
PtGen user manual - page 22