home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / Pascal / BPASCAL.700 / D11 / DDOCDEMO.ZIP / ENDCMD.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1992-10-01  |  2.1 KB  |  83 lines

  1. {************************************************}
  2. {                                                }
  3. {   Turbo Vision 2.0 Demo                        }
  4. {   Copyright (c) 1992 by Borland International  }
  5. {                                                }
  6. {************************************************}
  7.  
  8. program EndCmd;
  9.  
  10. uses Objects, App, Dialogs, Views, Drivers, Menus, MsgBox;
  11.  
  12. type
  13.   PButtonDialog = ^TButtonDialog;
  14.   TButtonDialog = object(TDialog)
  15.     constructor Init;
  16.   end;
  17.  
  18.   TEMApp = object(TApplication)
  19.     procedure HandleEvent(var Event: TEvent); virtual;
  20.     procedure InitStatusLine; virtual;
  21.   end;
  22.  
  23. const
  24.   cmDoDialog = 700;
  25.  
  26. constructor TButtonDialog.Init;
  27. var
  28.   R: TRect;
  29. begin
  30.   R.Assign(0, 0, 27, 8);
  31.   inherited Init(R, 'Press a button');
  32.   Options := Options or ofCentered;
  33.   R.Assign(2, 2, 12, 4);
  34.   Insert(New(PButton, Init(R, 'O~k~', cmOK, bfDefault)));
  35.   R.Assign(2, 5, 12, 7);
  36.   Insert(New(PButton, Init(R, 'Cancel', cmCancel, bfNormal)));
  37.   R.Assign(15, 2, 25, 4);
  38.   Insert(New(PButton, Init(R, '~Y~es', cmYes, bfNormal)));
  39.   R.Assign(15, 5, 25, 7);
  40.   Insert(New(PButton, Init(R, '~N~o', cmNo, bfNormal)));
  41.   SelectNext(False);
  42. end;
  43.  
  44. procedure TEMApp.HandleEvent(var Event: TEvent);
  45. var
  46.   ReturnVal: Word;
  47.   TheCommand: PString;
  48. const
  49.   CommandName: array[cmOK..cmNo] of string[8] =
  50.     ('cmOK', 'cmCancel', 'cmYes', 'cmNo');
  51. begin
  52.   inherited HandleEvent(Event);
  53.   if Event.What = evCommand then
  54.   begin
  55.     if Event.Command = cmDoDialog then
  56.     begin
  57.       ReturnVal := ExecuteDialog(New(PButtonDialog, Init), nil);
  58.       TheCommand := @CommandName[ReturnVal];
  59.       MessageBox(#3'Modal state ended'#13#3'with command %s.',
  60.          @TheCommand, mfInformation or mfOKButton);
  61.     end;
  62.   end;
  63. end;
  64.  
  65. procedure TEMApp.InitStatusLine;
  66. var
  67.   R: TRect;
  68. begin
  69.   GetExtent(R);
  70.   R.A.Y := R.B.Y - 1;
  71.   StatusLine := New(PStatusLine, Init(R, NewStatusDef(0, $FFFF,
  72.     NewStatusKey('~F3~ Open dialog box', kbF3, cmDoDialog,
  73.     NewStatusKey('~Alt+X~ Exit', kbAltX, cmQuit, nil)), nil)));
  74. end;
  75.  
  76. var
  77.   EMApp: TEMApp;
  78. begin
  79.   EMApp.Init;
  80.   EMApp.Run;
  81.   EMApp.Done;
  82. end.
  83.