Search Locate Previous Next Contents

How to Make a Simple Dialogue Box

This section should get you to the point where you are comfortable with the Causeway designer, and know how to investigate the various classes of object provided. The objective is to produce a very simple dialogue such as:


... and associate it with some variables in the workspace.

Let’s start by setting up the data and calling the dialogue designer:

      name„'Adrian'
      addr„'Brook House' 'Gilling East' 'York'
      eyes„1
      ‘eyecolour„'Blue' 'Brown' 'Green'
      Dbx 'dbx.rec'       © Save result in dbx.rec

It makes a lot of sense to keep with a naming convention such as dbx_xx or dbx.xxx (if you have a namespace called dbx) for all your Gui forms. This makes it much easier to analyse them for unused classes (for example using dbx.enum) or to search the actions for APL code.

Your completed screen layout will be saved in dbx.rec, which is a conventional APL 5-column array that can be viewed comfortably from the session. The first four columns give the object type, caption, position and size in pixels, with the origin at the upper left corner of the screen. Any properties you set for the objects are recorded in column-5 as a two-column matrix of property-value pairs.

You can, of course, modify or copy this matrix using APL in the normal way.

Here is the designer, with its floating property browser, as you should see it:


Exploring the Designer Toolbars

The leftmost buttons exit the designer, either saving your layout or discarding any changes. You can use Ctrl+E to exit (and save), Ctrl+S to save without exiting, Ctrl+A to save with a new name, or Ctrl+Q to quit. The centre two buttons invoke the ‘Object Sorter’ (to arrange the tab-order of controls) and the designer’s ‘Preferences’ dialogue (to set object spacing and framing parameters).

The ! button is reserved for future use with the CPro ‘Class Wizard’ and the ? button offers online help for the selected object and is activated with the F1 key. Finally, you can press the last button or hit F5 to run your form.

The Attach Toggles

Below the position/size fields is a bank of six toggling buttons which control how the object is attached to the edges of the parent form or subform. In this example, a field is attached both to height and to width, so that it will maintain its margins whatever you do to the form size. When you add a new object, it always attaches to the left edge and the top of the parent form. Positive positions measure the distance from the left (top) of the form to the left (top) of the object; negative positions measure from the right (bottom) to the right (bottom) edge of the object – note how the numbers change as the attachment of the object is toggled. The hot keys Ctrl+LRWTBH can be used as accelerators to attach the current object Left, Right etc.

The Lower Toolbar

The leftmost tool will centre the object horizontally. The second and third set the heights and widths of all selected objects to match the ‘senior’ object (see below). The next tool duplicates all the selected objects, and the following two tools set all selected objects to line up to the left or top edge of the senior object respectively (see the notes on Aligning and Arranging Objects for the way to use these effectively). Finally, you can choose to frame or delete the selected controls. All these tools have hot keys – hold the mouse over the tool for a pop-up tip.

Note that the toolbar may be set to float on top of the form you are designing, so that you can work on full-screen forms with no problem – use the right-mouse button on the property-browser to switch it to ‘Ontop’.


Alternatively, you can roll the property box up out of the way with the button in the top right corner or <F8> which toggles the rolled-up state. All the properties are accessible from the right-mouse menu on each object, so you may find that this is a more comfortable way to work on a complex form. Windows-95 users will find that the ‘menu’ key can be used to pop up the right-mouse menu, and that all the standard options now have hot-keys allocated on the menus.


Continue to: Adding Controls
© Copyright Causeway Graphical Systems Ltd 2001