home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / TOTDOC.ZIP / CHAPT10.TXT < prev    next >
Encoding:
Text File  |  1991-02-11  |  27.8 KB  |  723 lines

  1.                                                                       Displaying
  2.                                                                      Directories
  3.  
  4.  
  5.  
  6.  
  7.  
  8.          "An intellectual is someone who can listen to the William Tell overture
  9.          and not think of the Lone Ranger."
  10.  
  11.                                                                        Anonymous
  12.  
  13.  
  14.  
  15.  
  16.  
  17.          The Toolkit includes two entirely different object families for dis-
  18.          playing directory listings. The objects ListDirOBJ and ListDirSortOBJ
  19.          are descendant from ListOBJ and should be used when you want to display
  20.          the directory in a stretchable window, or let the user select multiple
  21.          files. The DirWinOBJ should be used when you want to display a file
  22.          selection dialog box and allow the user to choose a single file.
  23.  
  24.  
  25.  
  26. Displaying Directory List Windows
  27.  
  28.          The totLIST unit includes the ListDirOBJ object which is an adaptation
  29.          of ListOBJ. ListDirOBJ is designed to display files and directories in
  30.          a stretchable window. ListDirOBJ is a descendant of ListOBJ, and inher-
  31.          its all the following ListOBJ methods:
  32.  
  33.                     Init
  34.                     SetTopPick
  35.                     SetActivePick
  36.                     SetTagging
  37.                     SetColWidth
  38.                     Show
  39.                     Go
  40.                     LastKey
  41.                     GetHiString
  42.                     Win^
  43.                     Done
  44.  
  45.          Some of the list defaults are influenced by LookTOT^ methods. Refer
  46.          back to page 9-20 for a full description of these methods.
  47.  
  48.          In addition to the inherited methods, ListDirOBJ includes the following
  49.          important method:
  50.  
  51.  
  52.          ReadFiles(Filemasks:string; FileAttrib:word);
  53.  
  54.          This method must be called before the Go method. ReadFiles instructs
  55.          the object to read all the files matching the first parameter. The
  56.          filemask should include wild cards, e.g. *.pas, *.*, bob?.tit, etc.,
  57.          and may optionally include a drive and path. If a drive/path is not
  58.          specified, all matching files in the default directory will be read.
  59.          Note that the string may include more than one file specification sepa-
  60.          rated by spaces, e.g. '*.pas *.asm'. The second parameter identifies
  61.          the attributes of the files to include in the list.
  62.  
  63. 10-2                                                                User's Guide
  64.  
  65. --------------------------------------------------------------------------------
  66.  
  67.          The Turbo Pascal DOS unit includes the following file attribute con-
  68.          stants:
  69.  
  70.                     ReadOnly        = $01
  71.                     Hidden          = $02
  72.                     SysFile         = $04
  73.                     VolumeID        = $08
  74.                     Directory       = $10
  75.                     Archive         = $20
  76.                     AnyFile         = $3F
  77.  
  78.          Specify any of the desired file types by summing these constants and
  79.          passing them as the second parameter. For example, the following method
  80.          call will list all the .TXT files that can be edited:
  81.  
  82.                   ReadFiles('*.TXT',Anyfile-ReadOnly-Hidden);
  83.  
  84.          Note that the Toolkit automatically removes the VolumeID file from the
  85.          list.
  86.  
  87.          In summary, to display a basic file listing, all you have to do is
  88.          declare an instance of ListDirOBJ, and then call the methods Init,
  89.          ReadFiles and Go. The chosen file can be determined by calling the
  90.          function method GetHiString. Listed below is the demo file DEMDR1.PAS
  91.          which displays a simple directory, followed by figure 10.1 showing the
  92.          resultant list.
  93.  
  94.  
  95.  
  96.          program DemoDirectoryOne;
  97.          {demdr1 - the default directory list}
  98.  
  99.          Uses DOS, CRT,
  100.               totFAST, totLIST;
  101.  
  102.          Var
  103.             ListWin:  ListDirObj;
  104.  
  105.          begin
  106.             Screen.Clear(white,'░'); {paint the screen}
  107.             with ListWin do
  108.             begin
  109.                Init;
  110.                ReadFiles('*.*',AnyFile);
  111.                Go;
  112.                Win^.Remove;
  113.                if (LastKey = 27) or (Lastkey = 600) then
  114.                   writeln('You escaped!')
  115.                Else
  116.                   writeln('You chose file '+GetHiString);
  117.                Done;
  118.             end;
  119.          end.
  120.  
  121.  
  122.  
  123.  
  124. Displaying Directories                                                      10-3
  125.  
  126. --------------------------------------------------------------------------------
  127.  
  128. Figure 10.1                                                             [SCREEN]
  129. A Basic Directory
  130. List
  131.  
  132.  
  133.  
  134. Determining Tagged Files
  135.  
  136.          By default, the user can select multiple files by hitting the [KEYCAP]
  137.          or clicking the left mouse button on a filename. The method SetTagging
  138.          can be used to enable or disable multiple file tagging.
  139.  
  140.          The ListDirOBJ object implements the methods GetStatus and SetStatus to
  141.          provide access to tagged files. These methods work in precisely the
  142.          same way as their namesakes in the DLLOBJ family. Full descriptions can
  143.          be found on page 9-27, but in brief, GetStatus returns a boolean to
  144.          indicate whether the file has been tagged, and is passed two parame-
  145.          ters; the first parameter is the number of the file in the list, and
  146.          the second is the flag ID which should be set to 0 (zero) to check the
  147.          status of the tag flag.
  148.  
  149.          Each ListDirOBJ instance includes a FileDLLOBJ object which is a linked
  150.          list holding all the file details. The ListDirOBJ object provides the
  151.          method FileList which returns a pointer to the FileDLLOBJ list. This is
  152.          useful when you want to directly manipulate the file linked list. You
  153.          may recall that all DLLOBJ objects have a method TotalNodes which
  154.          returns a longint identifying the number of entries in the list. The
  155.          ListDirOBJ method FileList^.TotalNodes therefore returns the total num-
  156.          ber of files in the list.
  157.  
  158.          The demo program DEMDR2.PAS, listed below, shows how the methods GetS-
  159.          tatus and FileList^.TotalFiles can be used to ascertain which files the
  160.          user tagged. Notice that you must access the tagged files before
  161.          calling the method Done - otherwise, the list will be disposed of
  162.          before you can access it! Following the listing are figures 10.2 and
  163.          10.3 which provide an example of the output generated by the program.
  164.          Note that the highlighted file will only be included in the list if the
  165.          file is tagged.
  166.  
  167.          program DemoDirectoryTwo;
  168.          {demdr2 - determining chosen files}
  169.  
  170.          Uses DOS, CRT,
  171.               totFAST, totLIST;
  172.  
  173.          Var
  174.             ListWin:  ListDirObj;
  175.             Tot,L:longint;
  176.  
  177.          begin
  178.             Screen.Clear(white,'░'); {paint the screen}
  179.             with ListWin do
  180.             begin
  181.  
  182.  
  183.  
  184.  
  185. 10-4                                                                User's Guide
  186.  
  187. --------------------------------------------------------------------------------
  188.  
  189.                Init;
  190.                ReadFiles('*.*',AnyFile);
  191.                Go;
  192.                Win^.Remove;
  193.                if (LastKey = 27) or (Lastkey = 600) then
  194.                   writeln('You escaped!')
  195.                Else
  196.                begin
  197.                   writeln('The highlighted file was '+GetHiString);
  198.                   writeln('The tagged files were: ');
  199.                   Tot := FileList^.TotalNodes;
  200.                   for L := 1 to Tot do
  201.                       if GetStatus(L,0) then
  202.                          writeln(GetString(L,0,0));
  203.                end;
  204.                Done;
  205.             end;
  206.          end.
  207.  
  208.  
  209.  
  210.  
  211. Figure 10.2                                                             [SCREEN]
  212. Tagging Multiple
  213. Files
  214.  
  215. Figure 10.3                                                             [SCREEN]
  216. Displaying the
  217. Tagged Files
  218.  
  219.  
  220.  
  221. Advanced Directory Management
  222.  
  223.          In the previous section you learned that the method FileList returns a
  224.          pointer to an instance of type FileDLLOBJ which contains a list of all
  225.          the files selected for display. In addition to the TotalNodes method,
  226.          you can call any of the other FileDLLOBJ methods. Remember that these
  227.          methods must be called via the FileList method using the syntax:
  228.  
  229.                   FileList^.method
  230.  
  231.  
  232.  
  233. Sorting
  234.  
  235.          The Sort method can be used to sort the directory listing. This method
  236.          is described on page 9-6, and has the following syntax:
  237.  
  238.                   FileList^.Sort(SortID:shortint;Ascending:boolean);
  239.  
  240.          When used with a FileDLLOBJ object, the first parameter instructs the
  241.          Toolkit about which element of the file to sort by. The permissible
  242.          values are as follows:
  243.  
  244.  
  245.  
  246. Displaying Directories                                                      10-5
  247.  
  248. --------------------------------------------------------------------------------
  249.  
  250.               0     DOS (unsorted)
  251.               1     Name
  252.               2     Ext
  253.               3     Size
  254.               4     Time
  255.  
  256.          For example, calling the method Sort(2,false) will sort the files by
  257.          filename extension in descending order.
  258.  
  259.  
  260.  
  261. Accessing File Details
  262.  
  263.          The totLINK unit includes the following type declaration:
  264.  
  265.                   tFileInfo = record
  266.                      Filename: string[12];
  267.                      Attr: byte;
  268.                      Time:longint;
  269.                      Size:longint;
  270.                      LoadID: longint;
  271.                   end;
  272.  
  273.          Every node in a FileDLLOBJ list contains such a record, describing all
  274.          the file details. The first four fields in the record are the same as
  275.          the corresponding fields in the Turbo Pascal SearchRec record. The
  276.          fifth record LoadID is the node number when the file was added to the
  277.          list. This field is required so the list can be sorted in DOS order,
  278.          i.e. the order in which the files are stored in the DOS directory.
  279.  
  280.          The FileDLLOBJ method GetFileRecord can be used to access a file's
  281.          record, and the method GetLongStr can be used to access a string
  282.          detailing the file information. The syntax of these methods is as fol-
  283.          lows:
  284.  
  285.  
  286.          FileList^.GetFileRecord(var Info:tFileInfo; NodeNumber:longint);
  287.  
  288.          The first parameter must be a variable of type tFileInfo. This variable
  289.          is updated with the file details for the file specified by the second
  290.          parameter.
  291.  
  292.  
  293.          FileList^.GetLongStr(Node:DLLNodePtr): string;
  294.  
  295.          This method is passed a pointer to the list node, and returns a for-
  296.          matted string representing the node's file details. Remember that the
  297.          method FileList^.NodePtr can be used to return a node pointer.
  298.  
  299.  
  300.  
  301. 10-6                                                                User's Guide
  302.  
  303. --------------------------------------------------------------------------------
  304.  
  305. Refreshing the File List
  306.  
  307.          In the last chapter you learned that you can intercept all characters
  308.          pressed while a list is active, by assigning a character hook, or by
  309.          creating a descendant method and replacing the virtual method CharTask.
  310.          Thanks to OOP inheritance, these techniques can also be used with List-
  311.          DirOBJ objects.
  312.  
  313.          The FileList linked list can be directly modified using some FileDLLOBJ
  314.          methods. Ordinarily, you wouldn't need to call these methods, but if
  315.          you want to modify the displayed list "on the fly" from a character
  316.          hook, you can use the following methods:
  317.  
  318.  
  319.          FileList^.GetFileMask:string;
  320.  
  321.          This function returns the currently active file mask.
  322.  
  323.  
  324.          FileList^.SetFileDetails(FileMasks:string; FileAttrib:word);
  325.  
  326.          Specifies a new set of file masks and file attributes. This method must
  327.          be called prior to FillList.
  328.  
  329.  
  330.          FileList^.FillList;
  331.  
  332.          Empties the list (if it already contains files), and re-populates the
  333.          list with the new category of files.
  334.  
  335.  
  336.          FileList^.FillNewMask(Filemasks:string);
  337.  
  338.          This method re-populates the list with all files matching the FileMasks
  339.          parameter, which have the same attributes that were used when the list
  340.          was last filled.
  341.  
  342.  
  343.  
  344. Example
  345.  
  346.          The demo program DEMDR3.PAS, listed below, illustrates some of the
  347.          techniques discussed in this section. Figure 10.4 shows the resultant
  348.          output.
  349.  
  350.          program DemoDirectoryThree;
  351.          {demdr3 - a customized directory list}
  352.  
  353.          Uses DOS, CRT,
  354.               totFAST, totLINK, totLIST;
  355.  
  356.          Var
  357.             ListWin:  ListDirObj;
  358.             FileInfo: tFileInfo;
  359.  
  360.  
  361.  
  362. Displaying Directories                                                      10-7
  363.  
  364. --------------------------------------------------------------------------------
  365.  
  366.          begin
  367.             Screen.Clear(white,'░'); {paint the screen}
  368.             with ListWin do
  369.             begin
  370.                Init;
  371.                SetTagging(false);
  372.                ReadFiles('*.*',AnyFile - directory); {exclude directories}
  373.                FileList^.Sort(1,true);               {sort in name order}
  374.                Win^.SetTitle(' Choose a file ');
  375.                Go;
  376.                Win^.Remove;
  377.                if (LastKey = 27) or (Lastkey = 600) then
  378.                   writeln('You escaped!')
  379.                Else
  380.                begin
  381.                   writeln('You chose file '+GetHiString);
  382.                   writeln(FileList^.GetLongStr(FileList^.ActiveNodePtr));
  383.                   FileList^.GetFileRecord(FileInfo,
  384.                                           FileList^.ActiveNodeNumber);
  385.                   with FileInfo do
  386.                   begin
  387.                      writeln('Name:           ', FileName);
  388.                      writeln('Attr:           ', Attr);
  389.                      writeln('Packed Time:    ', Time);
  390.                      writeln('Size:           ', Size);
  391.                      writeln('Directory entry:',LoadID);
  392.                   end;
  393.                end;
  394.                Done;
  395.             end;
  396.          end.
  397.  
  398.  
  399.  
  400.  
  401. Figure 10.4                                                             [SCREEN]
  402. Advanced Directory
  403. Control
  404.  
  405.  
  406.  
  407. Displaying Sortable Directories
  408.  
  409.          ListDirSortOBJ is a descendant of ListDirOBJ, and shares all the meth-
  410.          ods of its ancestor. ListDirSort works in just the same way as ListDi-
  411.          rOBJ, with one added bonus - the user can press the right mouse button
  412.          or [KEYCAP] to display a sort dialog box. This allows the end user to
  413.          sort the file list in any order.
  414.  
  415.          Listed below is the demo program DEMDR4.PAS, followed by figure 10.5
  416.          showing the sort dialog box.
  417.  
  418.  
  419. 10-8                                                                User's Guide
  420.  
  421. --------------------------------------------------------------------------------
  422.  
  423.          program DemoDirFour;
  424.          {demdr4 - a user sortable directory listing}
  425.  
  426.          Uses DOS, CRT,
  427.               totFAST, totLIST;
  428.  
  429.          Var
  430.             ListWin:  ListDirSortOBJ;
  431.  
  432.          begin
  433.             Screen.Clear(white,'░'); {paint the screen}
  434.             Screen.WriteCenter(25,white,' Press S or Right Mouse Button
  435.                                           for Sort Options ');
  436.             with ListWin do
  437.             begin
  438.                Init;
  439.                ReadFiles('*.*',AnyFile);
  440.                Go;
  441.                Done;
  442.             end;
  443.          end.
  444.  
  445.  
  446.  
  447.  
  448. Figure 10.5                                                             [SCREEN]
  449. The Sort Dialog
  450. Box
  451.  
  452.  
  453.  
  454. Displaying Directories                                                      10-9
  455.  
  456. --------------------------------------------------------------------------------
  457.  
  458. Displaying a Directory Dialog Window
  459.  
  460.          In the unit totDIR, the Toolkit provides an alternative object for
  461.          displaying a directory dialog box. Figure 10.6 shows how the dialog box
  462.          looks to the user. The display is generated using a DirWinOBJ, and it
  463.          is ideal for prompting the user to enter a filename.
  464.  
  465.          The user can enter a file name, or a file mask, into the filename
  466.          field. If a file mask is entered, the file list is automatically
  467.          updated to reflect the new mask. The user can move from field to field
  468.          by pressing the [KEYCAP] and [KEYCAP] keys. As in the Turbo 6 environ-
  469.          ment, the user can choose a file from the file list by cursoring to the
  470.          desired file and pressing [KEYCAP]. The user can change directories or
  471.          drives by tabbing to the directory list, highlighting the desired
  472.          directory, and pressing [KEYCAP]. The user can also tab to the buttons
  473.          and select OK, Cancel or Help. Alternatively, the buttons can be
  474.          selected by pressing one of the hotkeys [KEYCAP], [KEYCAP] or [KEYCAP].
  475.  
  476.          A mouse user simply clicks on a field to activate it, and double-clicks
  477.          to choose a specific file or directory.
  478.  
  479.  
  480.  
  481. Figure 10.6                                                             [SCREEN]
  482. A Pop-up Directory
  483. Window
  484.  
  485.  
  486.  
  487. Displaying a Basic Directory Window
  488.  
  489.          The DirWinOBJ is very easy to use, and has the following four main
  490.          methods:
  491.  
  492.  
  493.          Init;
  494.  
  495.          As always, this methods initializes the instance and must always be
  496.          called first.
  497.  
  498.  
  499.          Go:tAction;
  500.  
  501.          This is the "do it" method which instructs the Toolkit to display the
  502.          dialog window and wait for the user to choose a file. Go returns a
  503.          member of the enumerated type tAction to indicate whether the user
  504.          chose a file or escaped. This function will only return Finished or
  505.          Escaped.
  506.  
  507.  
  508.          GetChosenFile:string;
  509.  
  510.  
  511.  
  512. 10-10                                                               User's Guide
  513.  
  514. --------------------------------------------------------------------------------
  515.  
  516.          This function method should be called after Go, to determine which file
  517.          the user selected. The function returns the name the user entered in
  518.          the input field, or the active filename in the file list. Note you
  519.          should check the value returned by Go to check whether the user
  520.          escaped.
  521.  
  522.  
  523.          Done;
  524.  
  525.          This function should be called to dispose of the instance, and should
  526.          be called after the method GetChosenFile.
  527.  
  528.  
  529.          Listed below is the program DEMDR5.PAS which generated the display
  530.          shown in figure 10.6.
  531.  
  532.          program DemoDirFive;
  533.          {demdr5 - the directory dialog box}
  534.  
  535.          Uses DOS, CRT,
  536.               totFAST, totDir, totIO1;
  537.  
  538.          Var
  539.             DirWin: DirWinObj;
  540.             Result: tAction;
  541.          begin
  542.             Screen.Clear(white,'░'); {paint the screen}
  543.             with DirWin do
  544.             begin
  545.                Init;
  546.                Result := Go;
  547.                if Result = Finished then
  548.                   writeln('You chose file: ',GetChosenFile)
  549.                else
  550.                   writeln('You escaped!');
  551.                Done;
  552.             end;
  553.          end.
  554.  
  555.  
  556. Customizing the Window
  557.  
  558.          To provide further display control, the DirWinOBJ object also includes
  559.          the following customization methods:
  560.  
  561.  
  562.          SetFileDetails(StartDir:string; FileMasks:string; FileAttrib: word);
  563.  
  564.          By default, the Toolkit will display any file with a mask of '*.*' in
  565.          the default directory. Use this method to override the defaults. The
  566.          first parameter specifies the initial drive and directory to search.
  567.          The second parameter identifies the file mask which may include multi-
  568.  
  569.  
  570.  
  571. Displaying Directories                                                     10-11
  572.  
  573. --------------------------------------------------------------------------------
  574.  
  575.          ple file masks separated by spaces, e.g. '*.bat *.exe *.com'. The third
  576.          parameter specifies the attributes of the files to be included in the
  577.          list (see the file attribute list on page 10.2).
  578.  
  579.  
  580.          SetSortDetails(SortID:byte; SortOrder: boolean);
  581.  
  582.          Ordinarily, the files are sorted in name order. Use this method to
  583.          specify an alternate sort order. Refer to the sorting discussion on
  584.          page 10.5 for further information.
  585.  
  586.  
  587.          Win^:MoveWinPtr;
  588.  
  589.          The method Win returns a pointer to the MoveWinOBJ instance on which
  590.          the window is drawn. By calling any MoveWinOBJ method using the syntax
  591.          Win^.method, you control the appearance of the window.
  592.  
  593.  
  594.  
  595.            Note: the DirWinOBJ is a hybrid of a number of other Toolkit
  596.            objects, and the way to control all the colors is not obvious. The
  597.            overall background, title, box border and file details are con-
  598.            trolled by the window, and the color is set with the method
  599.            Win^.SetColors. All other aspects of the dialog box are controlled
  600.            by the object IOTOT. The following IOTOT methods control the
  601.            directory display colors:
  602.  
  603.                     IOTOT^.SetColLabel (changes the box labels, e.g. Name:)
  604.                     IOTOT^.SetColList (changes the file and dir lists)
  605.                     IOTOT^.SetColField (changes the filename input field
  606.                     IOTOT^.SetColButtons (changes the buttons)
  607.  
  608.            IOTOT is discussed fully in the next chapter.
  609.  
  610.  
  611.  
  612.  
  613.          Listed below is the demo program DEMDR6.PAS which illustrates how to
  614.          customize the directory display using the above methods, and figure
  615.          10.7 shows the resultant output:
  616.  
  617.          program DemoDirSix;
  618.          {demdr6 - customizing the directory dialog box}
  619.  
  620.          Uses DOS, CRT,
  621.               totFAST, totDir, totIO1;
  622.  
  623.          Var
  624.             DirWin: DirWinObj;
  625.             Result: tAction;
  626.          begin
  627.             Screen.Clear(white,'░'); {paint the screen}
  628.  
  629.  
  630.  
  631.  
  632. 10-12                                                               User's Guide
  633.  
  634. --------------------------------------------------------------------------------
  635.  
  636.             with DirWin do
  637.             begin
  638.                Init;
  639.                SetFileDetails('','*.EXE *.COM *.BAT',AnyFile);
  640.                SetSortDetails(2,true);
  641.                Win^.SetColors(15,15,15,11);
  642.                IOTOT^.SetColLabel(15,15,15,15);
  643.                IOTOT^.SetColList(7,7,112,112);
  644.                IOTOT^.SetColField(7,112,8,8);
  645.                IOTOT^.SetColButton(112,126,127,126);
  646.                Result := Go;
  647.                if Result = Finished then
  648.                   writeln('You chose file: ',GetChosenFile)
  649.                else
  650.                   writeln('You escaped!');
  651.                Done;
  652.             end;
  653.          end.
  654.  
  655.  
  656.  
  657. Figure 10.7                                                             [SCREEN]
  658. Customizing the
  659. Directory Window
  660.  
  661.  
  662.  
  663. On-Screen Help
  664.  
  665.          By default, the Help key displays a simple message window describing
  666.          how to select a file (see figure 10.8). You can substitute your own
  667.          help dialog if necessary.
  668.  
  669.  
  670.  
  671. Figure 10.8                                                             [SCREEN]
  672. The Default Help
  673. Display
  674.  
  675.  
  676.  
  677.          In the next chapter, you will learn all about the Toolkit's very power-
  678.          ful full screen input facility. The totDIR unit makes extensive use of
  679.          the totIO units to build the directory dialog box. To override the
  680.          default directory help, you need to access the full screen input man-
  681.          ager object. You will be very familiar with the manager by the end of
  682.          the next chapter, but for now, all you need to concentrate on is the
  683.          help facility.
  684.  
  685.          The DirWinOBJ object includes the function method Action which returns
  686.          a pointer to the dialog manager. By calling the dialog manager's own
  687.          method SetHelpHook, you can assign a special procedure to be called
  688.          when the user asks for help.
  689.  
  690.  
  691. Displaying Directories                                                     10-13
  692.  
  693. --------------------------------------------------------------------------------
  694.  
  695.          To create customized help, all you have to do is create a procedure
  696.          following some specific rules, and then call the DirWinOBJ method
  697.          Action^.SetHelpHook to instruct the Toolkit to use your procedure.
  698.  
  699.          For a procedure to be eligible as a help hook, it must adhere to the
  700.          following rules:
  701.  
  702.          Rule 1     The procedure must be declared as a FAR procedure. This can
  703.                     be achieved by preceding the procedure with a {$F+} compiler
  704.                     directive, and following the procedure with a {$F-} direc-
  705.                     tive. Alternatively, Turbo 6 users can use the new keyword
  706.                     FAR following the procedure statement.
  707.  
  708.          Rule 2     The procedure must be declared with one passed parameter of
  709.                     type word. This parameter indicates which field was high-
  710.                     lighted when help was pressed. The directory dialog fields
  711.                     have the following IDs:
  712.  
  713.                           1     File mask field
  714.                           2     File list field
  715.                           3     Directory list field
  716.                           4     OK button
  717.                           5     Cancel button
  718.                           65335 Help button (constant HelpID)
  719.  
  720.          Rule 3     The procedure must be at the root level, i.e. the procedure
  721.                     cannot be nested within another procedure.
  722.  
  723.          The following procedure declaration follows these rules:
  724.  
  725.                   {$F+}
  726.                   procedure MyHelpHook(ID:word);
  727.                   .....{procedure statements}
  728.                   end;
  729.                   {$F-}
  730.  
  731.  
  732.          The following method Action^.SetHelpHook is then called to instruct the
  733.          Toolkit to call your procedure when the user asks for help:
  734.  
  735.  
  736.          Action^.SetHelpHook(PassedProc:HelpProc);
  737.  
  738.          This method is passed the procedure name of a procedure declared using
  739.          the rules outlined above.
  740.  
  741.  
  742.  
  743.          The demo program DEMDR7.PAS, listed below, illustrates how to customize
  744.          the directory help. Figure 10.9 shows the help screen!
  745.  
  746.          program DemoDirSeven;
  747.          {demdr7 - customizing directory help}
  748.  
  749.  
  750.  
  751.  
  752. 10-14                                                               User's Guide
  753.  
  754. --------------------------------------------------------------------------------
  755.  
  756.          Uses DOS, CRT,
  757.               totFAST, totDir, totIO1, totMSG;
  758.  
  759.          Var
  760.             DirWin: DirWinObj;
  761.             Result: tAction;
  762.  
  763.          {$F+}
  764.          procedure NewHelp(ID:word);
  765.          {}
  766.          var  HelpWin: MessageOBJ;
  767.          begin
  768.             with HelpWin do
  769.             begin
  770.                Init(1,' Not Much Help ');
  771.                AddLine('');
  772.                Addline(' Honey, if you need help here, we got big problems! ');
  773.                AddLine('');
  774.                Show;
  775.                Done;
  776.             end;
  777.          end; {NewHelp}
  778.          {$F-}
  779.  
  780.          begin
  781.             Screen.Clear(white,'░'); {paint the screen}
  782.             with DirWin do
  783.             begin
  784.                Init;
  785.                Action^.SetHelpHook(NewHelp);
  786.                Result := Go;
  787.                if Result = Finished then
  788.                   writeln('You chose file: ',GetChosenFile)
  789.                else
  790.                   writeln('You escaped!');
  791.                Done;
  792.             end;
  793.          end.
  794.  
  795.  
  796.  
  797. Figure 10.9                                                             [SCREEN]
  798. Customized Help
  799.  
  800.  
  801.  
  802.