home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / PAS_ALL.ZIP / TI671.ASC < prev    next >
Encoding:
Text File  |  1992-02-28  |  5.4 KB  |  265 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.   PRODUCT  :  Turbo Pascal                           NUMBER  :  671
  9.   VERSION  :  6.0
  10.        OS  :  MS/PC DOS
  11.      DATE  :  February 28, 1992                        PAGE  :  1/4
  12.  
  13.     TITLE  :  Associating Help Features with Context Hints
  14.  
  15.  
  16.  
  17.  
  18.   {
  19.  
  20.   This program has context help associated with the
  21.   WINDOW selection in the main menu. The context help
  22.   for the radio buttons in the dialog is supported as
  23.   well.
  24.  
  25.   }
  26.   {$X+}
  27.  
  28.   program Hints;
  29.  
  30.   uses Objects, Drivers, Views, Menus, Dialogs, App, Gadgets;
  31.  
  32.   const
  33.     cmNewDialog     = 100;
  34.     hcMyDialog      = 300;
  35.     hcCheck1        = 100;          {Declare help context handles}
  36.     hcCheck2        = hcCheck1 + 1;
  37.     hcRunny         = 200;
  38.     hcMelted        = hcRunny + 1;
  39.  
  40.   type
  41.     PMyStatusLine = ^TMyStatusLine;
  42.     TMyStatusLine = object(TStatusLine)
  43.       function Hint(AHelpCtx : Word) : String; virtual; {Help   }
  44.                                                         {context}
  45.       procedure HandleEvent(var Event : TEvent); virtual;
  46.     end;
  47.  
  48.     TMyApp = object(TApplication)
  49.       constructor Init;
  50.       procedure HandleEvent(var Event: TEvent); virtual;
  51.       procedure InitMenuBar; virtual;
  52.       procedure InitStatusLine; virtual;
  53.       procedure NewDialog;
  54.     end;
  55.  
  56.     PDemoDialog = ^TDemoDialog;
  57.     TDemoDialog = object(TDialog)
  58.       MyStatusLine : PMyStatusLine;
  59.     end;
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.   PRODUCT  :  Turbo Pascal                           NUMBER  :  671
  75.   VERSION  :  6.0
  76.        OS  :  MS/PC DOS
  77.      DATE  :  February 28, 1992                        PAGE  :  2/4
  78.  
  79.     TITLE  :  Associating Help Features with Context Hints
  80.  
  81.  
  82.  
  83.  
  84.   function TMyStatusLine.Hint(AHelpCtx : Word):String;
  85.   begin     { Load Hint with corresponding menu string}
  86.             { in insertion order                      }
  87.     case AHelpCtx of
  88.       hcCheck1   : Hint := 'Tilset Cheese Selection';
  89.       hcCheck2   : Hint := 'Jarlsberg Cheese Selection';
  90.       hcmyDialog : Hint := 'DIALOG selection now pressed';
  91.       hcMelted   : Hint := 'Melted Radio Button';
  92.       hcRunny    : Hint := 'Runny Radio pressed';
  93.     else
  94.       Hint := '';
  95.     end;
  96.   end;
  97.  
  98.   procedure TMyStatusLine.HandleEvent(var Event : TEvent);
  99.   begin
  100.     TStatusLine.HandleEvent(Event);
  101.     Update;
  102.   end;
  103.  
  104.   constructor TMyApp.Init;
  105.   var
  106.     R : TRect;
  107.   begin
  108.     TApplication.Init;
  109.     GetExtent(R);
  110.     Dec(R.B.X);
  111.     R.A.X := R.B.X - 9; R.A.Y := R.B.Y - 1;
  112.   end;
  113.   { TMyApp }
  114.  
  115.   procedure TMyApp.HandleEvent(var Event: TEvent);
  116.   begin
  117.     TApplication.HandleEvent(Event);
  118.     if Event.What = evCommand then
  119.     begin
  120.       case Event.Command of
  121.         cmNewDialog: NewDialog;
  122.       else
  123.         Exit;
  124.       end;
  125.       ClearEvent(Event);
  126.     end;
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.   PRODUCT  :  Turbo Pascal                           NUMBER  :  671
  141.   VERSION  :  6.0
  142.        OS  :  MS/PC DOS
  143.      DATE  :  February 28, 1992                        PAGE  :  3/4
  144.  
  145.     TITLE  :  Associating Help Features with Context Hints
  146.  
  147.  
  148.  
  149.  
  150.   end;
  151.  
  152.   procedure TMyApp.InitMenuBar;
  153.   var
  154.     R: TRect;
  155.   begin
  156.     GetExtent(R);
  157.     R.B.Y := R.A.Y + 1;
  158.     MenuBar := New(PMenuBar, Init(R, NewMenu(
  159.       NewSubMenu('~F~ile', hcNoContext, NewMenu(
  160.         NewItem('E~x~it', 'Alt-X', kbAltX, cmQuit, hcNoContext,
  161.         nil)),
  162.       NewSubMenu('~W~indow', hcNoContext, NewMenu(
  163.          NewItem('~D~ialog','F2', kbF2, cmNewDialog, hcmyDialog,
  164.         nil)),
  165.       nil))
  166.     )));
  167.   end;
  168.  
  169.   procedure TMyApp.InitStatusLine;
  170.   var
  171.     R: TRect;
  172.   begin
  173.     GetExtent(R);
  174.     R.A.Y := R.B.Y - 1;
  175.     StatusLine := New(PMyStatusLine, Init(R,
  176.       NewStatusDef(0,0,
  177.         NewStatusKey('', kbF10, cmMenu,
  178.         NewStatusKey('~Alt-X~ Exit', kbAltX, cmQuit,
  179.         NewStatusKey('~Alt-F3~ Close', kbAltF3, cmClose,
  180.         nil))),
  181.       NewStatusDef(10,10,
  182.         nil,nil))));
  183.   end;
  184.  
  185.   procedure TMyApp.NewDialog;
  186.   var
  187.     Borland: PView;
  188.     Dialog: PDemoDialog;
  189.     R: TRect;
  190.     C: Word;
  191.   begin
  192.     R.Assign(20, 6, 60, 19);
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.   PRODUCT  :  Turbo Pascal                           NUMBER  :  671
  207.   VERSION  :  6.0
  208.        OS  :  MS/PC DOS
  209.      DATE  :  February 28, 1992                        PAGE  :  4/4
  210.  
  211.     TITLE  :  Associating Help Features with Context Hints
  212.  
  213.  
  214.  
  215.  
  216.     Dialog := New(PDemoDialog, Init(R, 'Demo Dialog'));
  217.     with Dialog^ do
  218.     begin
  219.       R.Assign(3, 3, 18, 5);
  220.       Borland := New(PCheckBoxes, Init(R,
  221.         NewSItem('~T~ilset',
  222.         NewSItem('~J~arlsberg',
  223.         nil)))
  224.       );
  225.       Borland^.HelpCtx :=hcCheck1;
  226.       Insert(Borland);
  227.       R.Assign(2, 2, 10, 3);
  228.       Insert(New(PLabel, Init(R, 'Cheeses', Borland)));
  229.       R.Assign(22, 3, 34, 5);
  230.       Borland := New(PRadioButtons, Init(R,
  231.         NewSItem('~R~unny',
  232.         NewSItem('~M~elted',
  233.         nil)))
  234.       );
  235.       Borland^.HelpCtx := hcRunny;
  236.       Insert(Borland);
  237.       R.Assign(21, 2, 33, 3);
  238.       Insert(New(PLabel, Init(R, 'Consistency', Borland)));
  239.       R.Assign(15, 8, 25, 10);
  240.       Insert(New(PButton, Init(R, '~O~k', cmOK, bfDefault)));
  241.       R.Assign(28, 8, 38, 10);
  242.       Insert(New(PButton, Init(R, 'Cancel', cmCancel, bfNormal)));
  243.     end;
  244.     DeskTop^.ExecView(Dialog);
  245.     Dispose(Dialog, Done);
  246.   end;
  247.   var
  248.     MyApp: TMyApp;
  249.  
  250.   begin
  251.     MyApp.Init;
  252.     MyApp.Run;
  253.     MyApp.Done;
  254.   end.
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.