home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Education
/
collectionofeducationcarat1997.iso
/
COMPUSCI
/
TOT11.ZIP
/
TOTDOC11.ZIP
/
CHAPT8.TXT
< prev
next >
Wrap
Text File
|
1991-02-11
|
17KB
|
396 lines
Displaying
Messages
&
Prompts
"As Miss America, my goal is to bring peace to the entire world and
then to get my own apartment."
Jay Leno
Introduction
The totMSG unit includes a variety of easy-to-use objects for display-
ing messages and prompts. A message is simply a pop-up window which is
displayed until the user presses [KEYCAP], [KEYCAP], or clicks the
mouse on the close icon/button. Similarly, a prompt is a pop-up window,
but the user must select one of the options displayed at the bottom of
the window. A prompt window can have two or three buttons. The buttons
come in two varieties: strip-buttons like the ones used in the Turbo
Pascal IDE, and box-buttons like the ones used by PC Tools and the
Norton Utilities.
The Object Hierarchy
Figure 8.1 illustrates the object hierarchy for the totMSG unit. The
base (or primitive) object is BaseMessageOBJ, and all the other messag-
ing objects descend from it. You should never declare an instance of
type BaseMessageOBJ, as it is an abstract object. Use one of the
following four descendant objects:
MessageOBJ This is the basic message displaying object. Between
one and twenty lines of text can be displayed in a
moveable window. At the bottom of the window is a
single strip-button, which defaults to the text
"OK". The user removes the window by clicking the
mouse on the button or close icon, or by pressing
[KEYCAP] or [KEYCAP].
ButtonMessageOBJ This object is a descendant of MessageOBJ and
operates in the same way. The only difference is
that the button is a box-button.
PromptOBJ The PromptOBJ object is descendant from the BaseMes-
sageOBJ, and should be used when you want to prompt
the user to choose a specific option. A message is
displayed in a moveable window, and two or three
strip-buttons are displayed. The user removes the
window by clicking on one of the buttons or the
close icon, or by pressing [KEYCAP]. The buttons can
8-2 User's Guide
--------------------------------------------------------------------------------
be selected in one of three ways: clicking on the
button, tabbing to a button and pressing [KEYCAP],
or pressing a button hotkey.
ButtonPromptOBJ This objects displays box-buttons, but in all other
aspects it operates like PromptOBJ.
Figure 8.1 [PICTURE]
Message
Object Hierarchy
This combination of objects provides you with ways of displaying
single, double and triple button messages, using strip- or box-buttons.
The decision to use strip- or box-buttons is solely cosmetic. The
strip-buttons are more "elegant", but the box-buttons are larger and
easier to select with the mouse.
Common Methods
Since all the objects are derived from the BaseMessageOBJ, they share a
set of common methods. The following three methods can (and should) be
used with any of the messaging objects:
Init(Style:byte;Tit:string);
The Init method is passed two parameters. The first is the window box
style, and the second, the window title. Refer to 5-7 for a discussion
of box styles and titles. As always, this method must be called before
any other.
AddLine(Str:string);
Call this method to add a line of text to the method. For example, if
you want to display five lines of text, call AddLine five times. Up to
twenty lines of text can be displayed in a message. The text should be
no more than seventy characters long. The first line of text is always
displayed on the first line of the window, i.e. immediately below the
title. To force a space between the title and the text, call AddLine
with an empty string, e.g. AddLine('');. Similarly, the buttons are
positioned directly below the last line of text. Just call Addline with
an empty string to force a gap between the text and the buttons. The
Toolkit automatically computes the size of the message window based on
the number of lines added, the width of the longest line, and the style
of button selected.
WinForm: WinFormPtr;
Messages & Prompts 8-3
--------------------------------------------------------------------------------
This function method returns a pointer to the Toolkit WinFormOBJ object
which is used to manage user input while the message is being dis-
played. You can use this function method to directly access the WinFor-
mOBJ methods with the following syntax: WinForm^.method. Refer to
chapter 11: Controlling User Input for a full discussion of WinFormOBJ.
Note: the colors used by the message objects are derived from two
sources. The display of the window border and the message text is
controlled by the window settings used by the WinForm object.
Although this object is not discussed until chapter 11, it is
worthwhile noting that you can modify the window colors with the
following method call: WinForm^.Win^.SetColors. For example:
MyMsg.WinForm^.Win^.SetColors(23,31,30,28);
The display color of the message buttons are controlled by the
default colors set in the global instance IOTOT. The following
method can be used to change the button colors: IOTOT^.SetColBut-
ton. For example:
IOTOT^.SetColButton(32,46,47,46);
Refer to chapter 11 for further information.
8-4 User's Guide
--------------------------------------------------------------------------------
Done;
This method disposes of all the memory used by the object instance, and
should always be called.
Simple Messages
The MessageOBJ and ButtonMessageOBJ objects are used for displaying
simple messages, i.e. an informational message where you don't want the
user to make a selection. The user just reads the message and removes
it.
Both these objects include the following method:
Show;
This method instructs the Toolkit to display the message window.
Listed below is the (by now familiar) example DEMMS1.PAS, followed by
figure 8.2 which illustrates the generated display.
program DemoMessageOne;
{demms1 - simple message}
Uses DOS, CRT,
totFAST, totMSG;
Var
MsgWin : MessageOBJ;
begin
Screen.Clear(white,'░'); {paint the screen}
with MsgWin do
begin
Init(1,' Message ');
AddLine('');