Contents
A boiler plate code generator for Borland Pascal® ObjectWindow programs

Contents

Overview

Program Code Summary

Dialog Code Summary

Using BoilerPlate to Generate Program Code

Using BoilerPlate to Generate Dialog Code

MenuHelp

All Menus

Program Code Menu

Dialog Code Menu

Copyright


Overview

BoilerPlate is a code generater for Borland Pascal and Turbo Pascal OWL programs.  It can be used to generate boilerplate (skeleton) code both for your main program and any dialogs it uses.

To use BoilerPlate, you start by designing your resources (menus, icons, cursors, dialogs, etc.) with Resource Workshop.  BoilerPlate reads the resulting .RC file, asks a few questions and then produces the code.  Normally, the code can be compiled and run to give you a feel for the results, but you'll still have to fill in the details to produce the final result you want.

See also:

Progam Code Summary

Dialog Code Summary


Program Code Summary

Here's a summary of the program code BoilerPlate generates:

 The object type declaration for both the application and main window.  The main window may be a descendent of TWindow or TDlgWindow.  The type declaration has method headings for all the methods listed below.

Your choice of names for the application, main window, program, class name, and window caption.

Skeleton response methods for:

constructor, destructor, SetupWindow, GetClassName, GetWindowClass.

All menu items.

Your choice of Window messages (wm_XXXX messages).

OWL methods you wish to override.

Statements for:

Loading your choice of icon, cursor, accelerator, and menu.

Loading the .RES and any .INC or .PAS files.

Your window style (ws_XXXX) and class style (cs_xxxx) selections.

TScroller code if desired.

For TDlgWindow descendents:

Instance pointers defined for dialogbox controls.

Appropriate InitResource calls for controls.

Response methods for control notification messages.


Dialog Code Summary

Here's a summary of the code BoilerPlate generates for your dialogs:

 A separate unit for the Dialog.  Your choice of names for for the unit, object name, etc.

Support for Borland Windows Custom Controls.

Code generated for:

Constant declarations and/or include file request.

Constructor, Destructor, SetupWindow.

Dialog transfer record.

Your choice of Window messages (wm_XXXX messages).

OWL methods you wish to override.

For each control, your choice of:

Instance variable definition.

InitResource statement.

Validator (TEdit).

Transfer record field.

Notification respose method.

A calling procedure to make calling up your dialog easier.

A short test program to test your new dialog unit.


Using BoilerPlate to Generate Program Code

Using Resource Workshop, design your program's resource file.  Assign identifiers to all menuitems, icons, accelerators, cursors, and dialogboxes.  Save the resource file in .RC format.

Start BoilerPlate and load the resource file (File|Open).

Select  Code|New|Program  to open up a program code window.

Select and fill out the Names... dialog.

Select and fill out the two Styles dialogs.

Select your menu, accelerator, icon, and cursor from the two Resources dialogs.

Select and fill out the two Methods dialogboxes.

Select  Code|Write Source|To Screen.   Examine the code displayed.  You may want to revise some of the choices previously made.

Write the source file to disk (Code|Write Source|To File).

In most cases, you'll be able to compile and run the Pascal file to check menu placement, window style, etc.

Now all you have to do is fill in the skeleton routines.


Identifiers

Resource Workshop allows you to define identifiers as:

Alphanumeric strings

An Alphamumeric assigned a numerical value

Numbers

Identifier definitions may be stored in an include file (.INC), a Pascal unit file (.PAS), or in the .RC file itself.

Any of these variations are suitable for BoilerPlate.  An Alphamumeric assigned a numerical value is probably the most suitable.

BoilerPlate often forms other symbols from the identifier alphanumeric.  This works out best if and underscore is used for the second or third character, as:

cm_SoSomething

idd_MyButton


Using BoilerPlate to Generate Dialog Code

Using Resource Workshop, design the dialogbox adding it to the other resources in the program resource file.  Assign identifiers to the dialog and any control which you wish to access from the program.  Controls with an identifier of  -1 will be ignored by BoilerPlate.  Save the resource file in .RC format.

Start BoilerPlate and load the resource file (File|Open).

Select  Code|New|Dialog Code  to open up a dialog code window.

Use  Dialogs|Select  to select the dialog to work with.

After selecting the dialog, fill out the Dialog Details Dialog with your choice of Names.

In the Controls Dialog, select the dialog controls of interest.  For each control, fill out the control details dialog as appropriate.

Select and fill out the two Methods dialogs.

Select  Code|Write Unit Source|To Screen.   Examine the code displayed.  You may want to revise some of the choices previously made.

Write the source file to disk (Code|Write Unit Source|To File).

Select  Code|Write Test Program  to construct a test program for the dialog.

In most cases, you'll be able to compile and run the test program to check dialog action.

Now all you have to do is fill in the skeleton routines.


Menu Help, All Menus

File

Open  F3

Restart

Save Desktop

Restore Desktop

Exit

Code

New | Program Code

New | Dialog Code

Windows

Cascade

Tile

Toggle Zoom  F5

Help

Contents  F1

TPW help

BPW help

About


Menu Help, Program Code Menu

Code

Write source

Names

Styles

Window styles	(TWindow)

Class styles

Resources

Menus/Accelerators	(TWindow)

Dialogs/Accelerators	(TDlgWindow)

Icons/Cursors

Methods

Windows Messages

Other Methods


Menu Help, Dialog Code Menu

Code

Write Unit Source

Write Test Program

Dialogs

Select

Details

Controls

Methods

Windows Messages

Other Methods


Select this menu item upon starting BoilerPlate to load your resource (.RC) file.


Use this command to write your program source code either to the screen or a disk file.

To write to a disk file, all option selections must be completed as indicated by a "»" mark preceding the menu items Names..., Styles, Resources, and Methods.


On completion of all option selections (the menubar items Dialogs, Controls..., and Methods must have a "»" mark), use this command to write your dialog unit code either to the screen or a disk file.


On completion of all option selections (the menubar items Dialogs, Controls..., and Methods must have a "»" mark), use this command to write your dialog test program code either to the screen or a disk file.


This command restarts BoilerPlate from the beginning.  All selections and data previously input will be lost.


Use this command to save your work while taking a coffee break.


This command restores the data previously saved.


Use this command to exit BoilerPlate.


Initiates a new program code window.  Only one program code window may be opened.


Initiates a new Dialog Code window.  A number of dialog code windows may be opened providing the dialogs are different.


Tile the windows.


Cascades the windows.


F5

Toggles the active window to either maximum or normal size.


Opens up the Names Dialog.


Opens up the Window Styles Dialog.


Opens up the Class Styles Dialog.


Allows selecting which dialog is to be processed.


Opens up the Dialog Details Dialog.


Opens up the Controls Dialog to allow the selection of the dialog controls to be processed.


Names Dialog

Main Window Ancestor

Choose TWindow for most applications.

Choose  TDlgWindow if you have designed a dialogbox to serve as your main window.

BWCC

Check if you're planning on using Borland Custom Controls.

TScroler

Check if you wish to have a TScroller associated with your main window (TWindow only).

Program, Main window, and Application Names

Choose appropriate names.  For the main window and application name, keep in mind that BoilerPlate will add a ' T ' in front of the name.  Hence

MyWindow

will become

TMyWindow

Class name

Choose a name that is not likely to conflict with another window class name.  If you're main window is to be a descendent of TDlgWindow, BoilerPlate will make sure this name corresponds to that used in the dialogbox definition when the dialogbox is later selected.

Caption

Choose you're main window caption.  This field may be left blank.


Window Styles
Window Styles Dialog  (TWindow only)

This dialogbox allows you to select the ws_XXXX style options for the program main window.

The left listbox contains the possible options, the right one, the selections.

To add a selection--

Select the option in the left listbox and press

or

Double click on the desired option

To remove a selection--

Select the option in the right listbox and press

or

Double click on the option to be removed

   returns the selections to the default ws_OverlappedWindow.

Note that ws_OverlappedWindow and ws_Caption are combinations of other bits.  Thus selecting ws_OverlappedWindow is equivalent to selecting a number of options.  The Result window at the bottom of the dialogbox shows the actual combined result which will appear in the source code.

See also : ws_XXXX Style Constants


ws_XXXX Style Constants

ws_Border	Will have thin border.  Can't be sized.

ws_Caption	Will have a title bar.  Can't be used with ws_DlgFrame.

ws_ClipChildren	Excludes the area occupied by child windows when painting the main window.

ws_DlgFrame	A window with a double border but no title.

ws_Hscroll	Will have a horizontal scrollbar.

ws_Maximize	Window will be maximum size.

ws_MaximizeBox	Will have a maximize box.

ws_Minimize	Window will start iconic.

ws_MinimizeBox	Will have a minimize box.

ws_OverlappedWindow	A combination of ws_Overlapped, ws_Caption, ws_SysMenu, ws_Thickframe, ws_Minimizebox, and ws_Maximizebox.  This is the default window style option.

ws_SysMenu	The window will have a System menu box.

ws_Thickframe	The window can be sized.

ws_Visible	Will be visible.

ws_Vscroll	Will have a vertical scrollbar.


Class Styles Dialog

This dialogbox allows you to select the cs_xxxx style options for the program main window.

The left listbox contains the possible options, the right one, the selections.

To add a selection--

Select the option in the left listbox and press

or

Double click on the desired option

To remove a selection--

Select the option in the right listbox and press

or

Double click on the option to be removed

   returns the selections to the default cs_Vredraw or cs_Hredraw.

The Result window at the bottom of the dialogbox shows the actual combined result which will appear in the source code.

See also : cs_xxxx Style Constants


cs_XXXX Style Constants

cs_ByteAlignClient	Aligns the window's client area on a byte boundary.

cs_ByteAlignWindow	Aligns the window on a byte boundary.

cs_ClassDC	Allocates one display context to be shared by all windows in the class.

cs_DblClks	Window can respond to double click messages.

cs_GlobalClass	Specifies that the window is an application Global class.

cs_Hredraw	Redraw the window completely if the horizontal size is changed.

cs_NoClose	Window can't be closed.

cs_OwnDC	Allocates a unique display context for each window in the class.

cs_SaveBits	Saves the portion of the screen image that is obscured by another window.

cs_Vredraw	Redraw the window entirely if its vertical size is changed.


Opens up the Menu/Accelerator Dialog


Menus/Accelerators
Menus/Accelerators dialog  (TWindow only)

In this dialogbox, you can choose the menu and accelerator for your main window from among those found in the resource file.

If you have not yet designed either the menu or the accelerator, you can use the edit box to enter the name or value you intend to use.

If you're omitting either a menu or an accelerator, select 0 for that particular category.


Opens up the Dialog/Accelerators Dialog


Dialogboxes/Accelerators
Dialogs/Accelerators dialogbox  (TDlgWindow only)

In this dialogbox, you can choose the main window dialogbox and accelerator from among those found in the resource file.

If you have not yet designed either the dialogbox or the accelerator, you can use the edit box to enter the name or value you intend to use.

If not using an accelerator, select 0 for that particular category.


Identifiers may entered in symbolic or numeric form as:

MyIcon

103


Opens up the Icon/Cursor Dialog


Icon/Cursor
Icons/Cursors Dialog

Icons

Select an icon from the left listbox which shows the icons found in the resource file as well as the Windows standard icon.  If you're planning on drawing your own icon in the program, select 0.

Cursors

Select a cursor from the right listbox which shows the cursors found in the resource file as well as the Windows standard cursors. If you are planning on changing cursors often, you should probably select 0 here.

If you have not yet designed either your icon or the cursor, you can use the appropriate edit box to enter the name or value you intend to use.


Windows StandardCursors

idc_Arrow	The traditional arrow cursor

idc_Cross	Cross hairs

idc_Ibeam	The I beam editing cursor

idc_UpArrow	Arrow pointing straight up

idc_Wait	The hour glass


Opens up the Windows Messages Dialog to enable selection of the Windows messages to be processed.


Opens up the Other Methods Dialog to enable selection of the OWL methods to be overridden.


windows messages
Windows Messages Dialog

This dialogbox allows you to select the window messages that you wish your program or dialog to process.

The left listbox contains a list of commonly intercepted messages, the right one, the selections.

To add a selection--

Select the window message in the left listbox and press

or

Double click on the desired message

To remove a selection--

Select the windows message in the right listbox and press

or

Double click on the message to be removed

Not all possible window messages are listed.  However, you may enter other messages in the edit box and add them also.


other methods
Other Methods Dialog

This dialogbox allows you to select from a  list of OWL methods that you may wish to override.

The left listbox contains a list of OWL window methods, the right one, the selections.

To add a selection--

Select the method in the left listbox and press

or

Double click on the desired method

To remove a selection--

Select the method in the right listbox and press

or

Double click on the method to be removed

Not all OWL methods are listed.  Using the edit box, you can enter other OWL methods or even procedures of your own and Add them. However, you should also enter the parameter list with the procedure name. BoilerPlate will enter them as virtual procedures.


Additional Menus Dialog

At this point, you've selected the menu you want to install when your program starts.  Additional menus were found in the resource file.  If you're planning on using more that one menu in your program, you'll probably want to have response methods for the commands in those menus also.  This dialog gives you the opportunity to select additional menus whose menuitems you wish to include.

To add a selection--

Select the menu in the left listbox and press

or

Double click on the desired method

To remove a selection--

Select the menu in the right listbox and press

or

Double click on the method to be removed


Help|Contents brings up the contents section of this help file.


This menu selection brings up the Turbo Pascal help file for TPW version 1.0 and 1.5.  In order for this command to work, the file TPW.HLP must be somewhere on your path.


This menu selection brings up the help file for Borland Pascal version 7.0.  In order for this command to work, the file BPW.HLP must be somewhere on your path.


The about box gives copyright and version information.


Copyright
© Copyright 1992-4 by L. David Baldwin.

All Rights Reserved

BoilerPlate may be copied and distributed freely providing that no fee is charged and it is not part of a package for which a charge is made.

Problems, Bugs?  Contact me by Compuserve (the best way) or at one of the addresses below.

Dave Baldwin

CompuServe ID #76327,53

22 Fox Den Rd., (Summer)

Hollis, NH 03049

(603) 465-7857

144 13th St. East,  (Winter)

Tierra Verde, FL 33715

(813) 867-3030


TDlgWindow
TDlgWindow Descendants

If your main window is going to contain dialogbox controls such as edit boxes, listboxes, buttons, you should consider making it a descendent of TDlgWindow rather that TWindow.  It's a lot easier to lay out controls in the resource editor than it is to guess at positions and sizes.  You save some coding too.

Here's a couple of points regarding TDlgWindow descendents:

When you design your main window dialog, make sure you give it a class name.  Enter the same class name in the BoilerPlate's Names dialog.  (Actually, BoilerPlate will pick up the name when you select the main window dialog.)

A menu is optional.  The menu is designed in the usual way, but its identifier is assigned to the dialog in the dialogbox editor.


Control Detail Dialog

This dialog allows further specification of the code to be generated for each control.

Object Pointer Name

This field is already filled in and should only be changed if the control is a derived control.

Instance Variable

Check this if an you desire an instance variable for the control to be defined.  If checked, also fill in the Instance Variable Name field.

Transfer Field

Check this if a transfer field for the control is desired.  If checked, also fill in the Transfer Field Name field.  Some controls also require a field Size be specified.

If you find this item grayed, it's probably because you left the Transfer Record Name field blank in the Dialog Details Dialog indicating you didn't want a transfer record.

Notification Method

Check this if you wish to have a notification method for the control.  If checked, fill in the Method Name you desire for the notification method.  See also Notification Method Hints.

Validator	(TEdit only)

If you wish to have a validator for your Edit control, check its type here.  The Add button allow you to enter further information for the validator.

Note:  Validators are not supported in TPW.


Controls Dialog

This dialog lists all the controls in the selected dialog except for those with an identifier value of  -1.  You should select those controls which will require special action in your dialog.  As each control is selected, a Control Detail Dialog will come up allowing further input for that control.

To select a control:

Select it in the listbox and press

or

Double click on the control's name in the listbox

As controls are selected, a check mark will appear in the listbox.  If necessary, a control may be deselected using

When finished with this dialog, press


Dialog Detail Dialog

The fields of the Dialog are already filled in with default values mostly derived from the Dialog's identifier.  You may wish to change some of these defaults.

Ancestor

The new object's ancestor will almost always be TDialog.

Object Name

This will be the object name for this dialog.

Pointer Name

This will be the name of the pointer for this object.

Unit Name

The name of the unit.  The first eight characters will be the unit filename.

Transfer Record Name

The type name for the transfer record for this dialog.  This field may be left blank if no transfer record is desired.

Exec Procedure Name

The name given to a procedure for calling up the dialog.  This field may be left blank if the calling procedure is not desired.


Filter Validator

Valid Characters

Enter the allowable characters here.  These should be entered in set form as:

['a'..'f', 'A'..'F', '0'..'9']

['a','e','i','o','u']

Pointer Name

This field will already have the correct value.  Change it only if you are using a derived validator.


Picture String Characters and Examples

#	Accept only a digit

?	Accept only a letter (either case)

&	Accept only a letter, force to uppercase

@	Accept any character

!	Accept any character, force to uppercase

;	Take next character literally

*	Repeat next item or group 0 or more times.  If followed by a number, repeat that many times.

[]	Enclose options

{}	Enclose groups

,	(Comma) Separate items

All other characters taken literally

Examples:

@@*@	Two or more characters

[(###) ]###-####	Telephone number with optional area code

Red,B[lue,rown]	Red,Blue, or Brown

$*#[.##]	Currency


Picture String Validator

Picture String

Enter the desired picture string.  See Picture String Characters and Examples

Pointer Name

This field will already have the correct value.  Change it only if you are using a derived validator.

Auto Fill

Check this if you wish the validator to automatically fill in unambiguaous characters.

On Append

An undocumented option, normally on.  Best to leave it on unless you want to experiment.


Range Validator

Minimum

The minimum entry value permitted.

Maximum

The maximum entry value permitted.

Pointer Name

This field will already have the correct value.  Change it only if you are using a derived validator.

Transfer Method

This refers to the transfer record field for this TEdit.  Data may be transfered either by LongInt or by String.  If you choose String, be sure the Size entry for the TEdit is adequate.


Select Dialog

Select the dialog for which code is to be generated.


Hints for Designing a Dialog

Here are some miscellaneous hints for designing a dialog.  This is basically a list of things that puzzled me at one time or other.

Constants

Some commonly used constants such as cm_Exit, cm_FileOpen, etc. are unknown to Resource Workshop.  To remedy this, use File|Add to project to include OWINDOWS.INC (BPW) or WOBJECTS.H (TPW) in the project.  BUT be careful you don't add some of your own identifier definitions to this file.  (It might be best to use a copy.)

Hot Keys

In dialogs, hot keys are defined by inserting an '&' before the hot key letter.  When the hot key is entered, the next control with its tabstop set becomes active.  Therefore, its important to order the controls correctly.  So if you're using a Static for a label on an Edit control and expect the hot key definition to work, the Static must be ordered immediately before the Edit control.

Similarly, if you have a hot key definition in a groupbox caption, the groupbox should be ordered immediately before the first checkbox or radiobutton.

Checkboxes, Radiobuttons

Unless you're planning something unusual, checkboxes should be defined as Auto check boxes and radio buttons as Auto radio buttons.

The proper way to set up a group of checkboxes or radiobuttons is:

 	The first one should have its tabstop and group turned on.

 	The remainder should have these items turned off.

 	The next control after the checkboxes or radiobuttons should have its group turned on.

The easiest way to make a batch of radiobuttons/checkboxes is to make one and then use Resource Workshop's Edit|Duplicate command.


Notification Method Hints

Listboxes, Comboboxes

Listboxes and Comboboxes need a notification routine only if you want some immediate response to a selection.  If you plan on a notification method for a listbox, be sure the notification checkbox is checked in Resource Workshop.

Checkboxes, Radiobuttons

Properly configured checkboxes and radiobuttons need a notification method only if some special action is required.  An example might be the disabling or graying of some other control when the button is checked.  See Checkboxes, Radiobuttons.

Buttons

Push buttons other than OK and Cancel will always need a notification method in order for them to accomplish something.  OK and Cancel only need notification methods if you have something special in mind.

Edit Controls

I haven't found much use for notification routines for Edit controls.


Borland Custom Controls

BoilerPlate supports Borland custom controls.  If you're planning to use them in your program, check the BWCC box in the Names Dialog when generating program code.

For dialogs, BoilerPlate will sense when you've used Borland custom controls and make the appropriate code adjustments automatically.