home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
pascal
/
library
/
dos
/
tvision
/
diag
/
diag.pas
next >
Wrap
Pascal/Delphi Source File
|
1991-03-19
|
2KB
|
87 lines
{ diag.pas - Dialog Library }
{$x+}
UNIT Diag;
INTERFACE
USES Crt, Objects, Views, App, Dialogs;
PROCEDURE AboutProgram(ProgramTitle: String);
FUNCTION Yes(Prompt: String): Boolean;
PROCEDURE ErrorMessage(ErrNumber: Integer; ErrMessage: String);
IMPLEMENTATION
{-Display "About Program" dialog box }
PROCEDURE AboutProgram(ProgramTitle: String);
VAR
AboutPtr: PDialog;
R: TRect;
BEGIN
R.Assign(0, 0, 40, 11);
AboutPtr := New(PDialog, Init(R, 'About'));
IF (AboutPtr <> NIL) THEN WITH AboutPtr^ DO
BEGIN
Options := OPtions OR ofCentered;
R.Grow(-1, -1);
Insert(New(PStaticText, Init(R,
#13^C + ProgramTitle + #13 +
#13^C'Copyright (c) 1991'#13+
#13^C'by Tim Johnson'
)));
R.Assign(15, 8, 25, 10);
Insert(New(PButton, Init(R, 'O~K', cmOk, bfDefault)));
Desktop^.ExecView(AboutPtr);
Dispose(AboutPtr,Done)
END
END;
{-Prompt user for Yes or No answer. Returns true for Yes }
FUNCTION Yes(Prompt: String): Boolean;
VAR
YNDiag: PDialog;
R: TRect;
BEGIN
R.Assign(0, 0, 60, 7);
YNDiag:= New(PDialog, Init(R, 'Please answer Yes or No'));
IF (YNDiag <> NIL) THEN WITH YNDiag^ DO
BEGIN
Options := Options OR ofCentered;
R.Grow(-1, -2);
Insert(New(PStaticText, Init(R, ^C+Prompt)));
R.Assign(35, 4, 43, 6);
Insert(New(PButton, Init(R, '~N~o', cmNo, bfNormal)));
R.Assign(17, 4, 26, 6);
Insert(New(PButton, Init(R, '~Y~es', cmYes, bfDefault)));
Yes := Desktop^.ExecView(YNDiag)= cmYes;
Dispose(YNDiag, Done)
END
END;
{-Display error message }
PROCEDURE ErrorMessage(ErrNumber: Integer; ErrMessage: String);
VAR
ErrDiag: PDialog;
R: Trect;
ENS: String[6]; {Error-Number string}
BEGIN
Str(ErrNumber, ENS);
R.Assign(0, 0, 60, 7);
ErrDiag:= New(PDialog, Init(R, 'Error #' + ENS));
IF (ErrDiag<> NIL) THEN WITH ErrDiag^ DO
BEGIN
Options := Options OR ofCentered;
R.Grow(1, -2);
Insert(New(PStaticText, Init(R, ^C+ErrMessage)));
R.Assign(20, 4, 40, 6);
Insert(New(PButton, Init(R, '~O~k', cmOK, bfNormal)));
Sound(400);
Delay(200);
NoSound;
Desktop^.ExecView(ErrDiag);
Dispose(ErrDiag, Done)
END
END;
END.