home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / progm / tot5.zip / DEMLS8.PAS < prev    next >
Pascal/Delphi Source File  |  1991-02-11  |  2KB  |  100 lines

  1. program DemoListEight;
  2. {demls8 - using Message and Character hooks}
  3.  
  4. Uses DOS, CRT,
  5.      totFAST, totLINK, totLIST, totSTR, totMSG;
  6.  
  7. Var
  8.    ListWin:  ListLinkObj;
  9.    ItemList: StrDLLOBJ;
  10.    FileOK: boolean;
  11.  
  12. {$F+}
  13. function HelpHook(var K:word; var X,Y: byte; HiPick:longint): tListAction;
  14. {}
  15. var MsgWin: MessageOBJ;
  16. begin
  17.    HelpHook := None;
  18.    if K = 315 then
  19.    begin
  20.       with MsgWin do
  21.       begin
  22.          Init(6,'Kinda Help');
  23.          AddLine('');
  24.          AddLine('In a real application, this would');
  25.          AddLine('be a help screen, and it would give');
  26.          AddLine('help related to item '+IntToStr(HiPick)+'!');
  27.          AddLine('');
  28.          Show;
  29.          Done;
  30.       end;
  31.       K := 0;
  32.    end
  33.    else if K = 316 then {F2 so swap colors}
  34.    begin
  35.       ListWin.SetStatus(HiPick,1,not ListWin.GetStatus(HiPick,1));
  36.       K := 336; {emulate down cursor}
  37.    end;
  38. end; {HelpHook}
  39.  
  40. function MsgHook(HiPick:longint):string;
  41. {}
  42. begin
  43.    MsgHook := 'The Hi Pick is '+IntToStr(HiPick);
  44. end; {MsgHook}
  45. {$F-}
  46.  
  47. procedure LoadLinkedList;
  48. {}
  49. var 
  50.   F: text;
  51.   Line:string;
  52.   Result: integer;
  53. begin
  54.    with ItemList do
  55.    begin
  56.       Init;
  57.       {$I-}
  58.       Assign(F,'demls4.txt');
  59.       Reset(F);
  60.       {$I+}
  61.       FileOK := (IOResult = 0);
  62.       if not FileOK then
  63.          Result := Add('File not found')
  64.       else
  65.       begin
  66.          while not eof(F) do
  67.          begin
  68.             Readln(F,Line);
  69.             Result := Add(Line);
  70.          end;
  71.          close(F);
  72.       end;
  73.    end;
  74. end; {LoadLinkedList}
  75.  
  76. begin
  77.    Screen.Clear(white,'░'); {paint the screen}
  78.    Screen.WriteCenter(25,white,'  F1 Help   F2 Toggle Color!   [Space] Toggle Tag  ');
  79.    LoadLinkedList;
  80.    with ListWin do
  81.    begin
  82.       Init;
  83.       AssignList(ItemList);
  84.       SetColWidth(15);
  85.       SetCharHook(HelpHook);
  86.       SetMsgHook(MsgHook);
  87.       SetDualColors(true);
  88.       Win^.SetTitle(' A Multi-Colored List ');
  89.       Win^.SetSize(20,5,60,20,2);
  90.       Win^.SetMinSize(20,7);
  91.       if not FileOk then
  92.          SetTagging(false);
  93.       Go;
  94.       Done;
  95.    end;
  96.    ItemList.Done;
  97. end.
  98.  
  99.  
  100.