home *** CD-ROM | disk | FTP | other *** search
- {*******************************************************}
- { }
- { Turbo Pascal Version 6.0 }
- { Turbo Vision Unit }
- { }
- { Copyright (c) 1990 Borland International }
- { }
- {*******************************************************}
-
- unit MsgBox;
-
- {$F+,O+,X+,D-}
-
- interface
-
- uses crt,Objects;
-
- const
-
- { Message box classes }
-
- mfWarning = $0000; { Anzeige einer Warnung }
- mfError = $0001; { Anzeige eines Fehlers }
- mfInformation = $0002; { Anzeige einer Information }
- mfConfirmation = $0003; { Anzeige einer Bestätigung }
- mfHelp = $0004; { Anzeige einer Hilfe }
-
- { Message box button flags }
-
- mfYesButton = $0100; { Put a Yes button into the dialog }
- mfNoButton = $0200; { Put a No button into the dialog }
- mfOKButton = $0400; { Put an OK button into the dialog }
- mfCancelButton = $0800; { Put a Cancel button into the dialog }
-
- mfYesNoCancel = mfYesButton + mfNoButton + mfCancelButton;
- { Standard Yes, No, Cancel dialog }
- mfOKCancel = mfOKButton + mfCancelButton;
- { Standard OK, Cancel dialog }
-
- { MessageBox gibt einen String in der Standard-Größe in der Dialog- }
- { Box aus. Bevor der Dialog ausgegeben wird, wird Msg und Params }
- { an FormatStr übergeben. Der Ergebnis-String wird als ein TStaticTxt }
- { im Dialog-Fenster ausgegeben. }
-
- function MessageBox(Msg: String; Params: Pointer;
- XL,YL,AOptions: Word): Word;
-
- { MessageBoxRec erlaubt die Festlegung von TRect für die }
- { Messagebox als Einstellung}
-
- function MessageBoxRect(var R: TRect; Msg: String; Params: Pointer;
- AOptions: Word): Word;
-
- { MessageBoxGross gibt einen String in der Standard-Größe in der Dialog- }
- { Box aus. Bevor der Dialog ausgegeben wird, wird Msg und Params }
- { an FormatStr übergeben. Der Ergebnis-String wird als ein TStaticTxt }
- { im Dialog-Fenster ausgegeben. }
-
- function MessageBoxGross(Msg: String; Params: Pointer;
- Msg2: String; Params1: Pointer; Msg3: String;
- Params2: Pointer; XL,YL,AOptions: Word): Word;
-
- { MessageBoxRecGross erlaubt die Festlegung von TRect für die }
- { MessageboxGross als Einstellung}
-
- function MessageBoxRectGross(var R: TRect; Msg: String;Params: Pointer;
- Msg2: String;Params1: Pointer; Msg3: String; Params2: Pointer;
- AOptions: Word): Word;
-
- { InputBox gibt eine einfache Ausgabe heraus als Dialog }
- { der dem Nutzer erlaubt einen einfachen String einzugeben }
-
- function InputBox(Title: String; ALabel: String; var S: String;
- Limit: Byte): Word;
-
- { InputBoxRect ist wie InputBox, aber erlaubt die Specifikation }
- { eines Rechteckes. }
-
- function InputBoxRect(var Bounds: TRect; Title: String; ALabel: String;
- var S: String; Limit: Byte): Word;
-
- implementation
-
- uses Drivers, Views, Dialogs, App;
-
- function MessageBox(Msg: String; Params: Pointer;
- XL,YL,AOptions: Word): Word;
- var
- R: TRect;
- begin
- R.Assign(0, 0, XL, YL);
- R.Move((Desktop^.Size.X - R.B.X) div 2, (Desktop^.Size.Y - R.B.Y) div 2);
- MessageBox := MessageBoxRect(R, Msg, Params, AOptions);
- end;
-
- function MessageBoxRect(var R: TRect; Msg: String; Params: Pointer;
- AOptions: Word): Word;
- const
- ButtonName: array[0..3] of string[8] =
- ('~J~a', '~N~ein', 'O~K~', '~B~eenden');
- Commands: array[0..3] of word =
- (cmYes, cmNo, cmOK, cmCancel);
- Titles: array[0..4] of string[17] =
- (' Warnung ',' Fehler ',' Information ',' Bestätige ',' Hilfsanzeigen ');
- var
- I, X, ButtonCount: Integer;
- Dialog: PDialog;
- Control: PView;
- T: TRect;
- ButtonList: array[0..4] of PView;
- S: String;
- begin
- Dialog := New(PDialog,
- Init(R, Titles[AOptions and $3]));
- with Dialog^ do
- begin
- R.Assign(3, 2, Size.X - 2, Size.Y - 3);
- FormatStr(S, Msg, Params^);
- Control := New(PStaticText, Init(R, S));
- Insert(Control);
- X := -2;
- ButtonCount := 0;
- for I := 0 to 3 do
- if AOptions and ($0100 shl I) <> 0 then
- begin
- R.Assign(0, 0, 10, 2);
- Control := New(PButton, Init(R, ButtonName[I], Commands[i],
- bfNormal));
- Inc(X, Control^.Size.X + 2);
- ButtonList[ButtonCount] := Control;
- Inc(ButtonCount);
- end;
- X := (Size.X - X) shr 1;
- for I := 0 to ButtonCount - 1 do
- begin
- Control := ButtonList[I];
- Insert(Control);
- Control^.MoveTo(X, Size.Y - 3);
- Inc(X, Control^.Size.X + 2);
- end;
- SelectNext(False);
- end;
- MessageBoxRect := DeskTop^.ExecView(Dialog);
- Dispose(Dialog, Done);
- end;
-
- function MessageBoxGross(Msg: String;Params: Pointer; Msg2: String;
- Params1: Pointer; Msg3: String; Params2: Pointer;
- XL,YL,AOptions: Word): Word;
- var
- R: TRect;
- begin
- R.Assign(0, 0, XL, YL);
- R.Move((Desktop^.Size.X - R.B.X) div 2, (Desktop^.Size.Y - R.B.Y) div 2);
- MessageBoxGross := MessageBoxRectGross
- (R, Msg,Params,Msg2,Params1,Msg3,Params2, AOptions);
- end;
-
- function MessageBoxRectGross(var R: TRect; Msg: String;Params: Pointer;
- Msg2: String;Params1: Pointer; Msg3: String;Params2: Pointer;
- AOptions: Word): Word;
- const
- ButtonName: array[0..3] of string[8] =
- ('~J~a', '~N~ein', 'O~K~', '~B~eenden');
- Commands: array[0..3] of word =
- (cmYes, cmNo, cmOK, cmCancel);
- Titles: array[0..4] of string[17] =
- (' Warnung ',' Fehler ',' Information ',' Bestätige ',' Hilfsanzeigen ');
- var
- I, X, ButtonCount: Integer;
- Dialog: PDialog;
- Control: PView;
- T: TRect;
- ButtonList: array[0..4] of PView;
- S: String; S1:String; S2:String;
-
- begin
- {Ausgabe-Fenster mit max 3 String-Ausgaben, mit 4 bzw. 6 Zeilen)
- {die Größe ist abhänging von B.X und B.Y bzw. XL und YL }
-
- Dialog := New(PDialog,
- Init(R, Titles[AOptions and $4]));
- with Dialog^ do
- begin
- R.Assign(3, 2, Size.X - 2, Size.Y - 16);
- FormatStr(S, Msg, Params^);
- Control := New(PStaticText, Init(R, S));
- Insert(Control);
- R.Assign(3, Size.Y-15, Size.X - 2, Size.Y-11);
- FormatStr(S1, Msg2, Params1^);
- Control := New(PStaticText, Init(R, S1));
- Insert(Control);
- R.Assign(3, Size.Y-10, Size.X - 2, Size.Y - 4);
- FormatStr(S2, Msg3, Params2^);
- Control := New(PStaticText, Init(R, S2));
- Insert(Control);
- X := -2;
- ButtonCount := 0;
- for I := 0 to 3 do
- if AOptions and ($0100 shl I) <> 0 then
- begin
- R.Assign(0, 0, 10, 2);
- Control := New(PButton, Init(R, ButtonName[I], Commands[i],
- bfNormal));
- Inc(X, Control^.Size.X + 2);
- ButtonList[ButtonCount] := Control;
- Inc(ButtonCount);
- end;
- X := (Size.X - X) shr 1;
- for I := 0 to ButtonCount - 1 do
- begin
- Control := ButtonList[I];
- Insert(Control);
- Control^.MoveTo(X, Size.Y - 3);
- Inc(X, Control^.Size.X + 2);
- end;
- SelectNext(False);
- end;
- MessageBoxRectGross := DeskTop^.ExecView(Dialog);
- Dispose(Dialog, Done);
- end;
-
- function InputBox(Title: String; ALabel: String; var S: String;
- Limit: Byte): Word;
- var
- R: TRect;
- begin
- R.Assign(0, 0, 60, 8);
- R.Move((Desktop^.Size.X - R.B.X) div 2, (Desktop^.Size.Y - R.B.Y) div 2);
- InputBox := InputBoxRect(R, Title, ALabel, S, Limit);
- end;
-
- function InputBoxRect(var Bounds: TRect; Title: String; ALabel: String;
- var S: String; Limit: Byte): Word;
- var
- Dialog: PDialog;
- Control: PView;
- R: TRect;
- C: Word;
- begin
- Dialog := New(PDialog, Init(Bounds, Title));
- with Dialog^ do
- begin
- R.Assign(4 + CStrLen(ALabel), 2, Size.X - 3, 3);
- Control := New(PInputLine, Init(R, Limit));
- Insert(Control);
- R.Assign(2, 2, 3 + CStrLen(ALabel), 3);
- Insert(New(PLabel, Init(R, ALabel, Control)));
- R.Assign(Size.X - 24, Size.Y - 4, Size.X - 14, Size.Y - 2);
- Insert(New(PButton, Init(R, 'O~K~', cmOk, bfDefault)));
- Inc(R.A.X, 12); Inc(R.B.X, 12);
- Insert(New(PButton, Init(R, 'Beende', cmCancel, bfNormal)));
- Inc(R.A.X, 12); Inc(R.B.X, 12);
- SelectNext(False);
- end;
- Dialog^.SetData(S);
- C := DeskTop^.ExecView(Dialog);
- if C <> cmCancel then Dialog^.GetData(S);
- Dispose(Dialog, Done);
- InputBoxRect := C;
- end;
-
- end.
-