home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 5 / ctrom5b.zip / ctrom5b / PROGRAM / DELPHI / ORPHTR / LBUNIT.PAS < prev    next >
Pascal/Delphi Source File  |  1995-03-15  |  2KB  |  91 lines

  1. unit Lbunit;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  7.   Forms, Dialogs, OvcBase, OvcVlb, StdCtrls, Buttons;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     OvcVirtualListbox1: TOvcVirtualListbox;
  12.     Label1: TLabel;
  13.     Label2: TLabel;
  14.     BitBtn1: TBitBtn;
  15.     OvcController1: TOvcController;
  16.     procedure OvcVirtualListbox1GetItem(Sender: TObject; Index: Longint;
  17.       var ItemString: OpenString);
  18.     procedure OvcVirtualListbox1GetItemColor(Sender: TObject;
  19.       Index: Longint; var FG, BG: TColor);
  20.     procedure OvcVirtualListbox1Click(Sender: TObject);
  21.     procedure OvcVirtualListbox1IsSelected(Sender: TObject; Index: Longint;
  22.       var Selected: Boolean);
  23.     procedure OvcVirtualListbox1Select(Sender: TObject; Index: Longint;
  24.       Selected: Boolean);
  25.   private
  26.     { Private declarations }
  27.  
  28.     {maintain selection status of the first 500 items}
  29.     Select : array[0..500] of Boolean;
  30.   public
  31.     { Public declarations }
  32.   end;
  33.  
  34. var
  35.   Form1: TForm1;
  36.  
  37. implementation
  38.  
  39. {$R *.DFM}
  40.  
  41. procedure TForm1.OvcVirtualListbox1GetItem(Sender: TObject; Index: Longint;
  42.   var ItemString: OpenString);
  43. begin
  44.   {cheat and just return the index number as the item string}
  45.   ItemString := Format('Item # %d', [Index]);
  46. end;
  47.  
  48. procedure TForm1.OvcVirtualListbox1GetItemColor(Sender: TObject;
  49.   Index: Longint; var FG, BG: TColor);
  50. begin
  51.   if Index <> OvcVirtualListbox1.ItemIndex then begin
  52.     if Index mod 13 = 0 then
  53.       FG := clRed
  54.     else if Index mod 7 = 0 then
  55.       FG := clGreen
  56.     else if Odd(Index) then
  57.       FG := clBlue;
  58.   end;
  59. end;
  60.  
  61. procedure TForm1.OvcVirtualListbox1Click(Sender: TObject);
  62. var
  63.   I : LongInt;
  64. begin
  65.   I := OvcVirtualListbox1.ItemIndex;
  66.   if I > -1 then
  67.     Label2.Caption := Format('Item # %d', [I])
  68.   else
  69.     Label2.Caption := '(none)';
  70. end;
  71.  
  72. procedure TForm1.OvcVirtualListbox1IsSelected(Sender: TObject;
  73.   Index: Longint; var Selected: Boolean);
  74. begin
  75.   if Index <= 500 then
  76.     Selected := Select[Index]
  77.   else
  78.     Selected := False;
  79. end;
  80.  
  81. procedure TForm1.OvcVirtualListbox1Select(Sender: TObject; Index: Longint;
  82.   Selected: Boolean);
  83. begin
  84.   if Index = -1 then
  85.     FillChar(Select, SizeOf(Select), Selected)
  86.   else if Index <= 500 then
  87.     Select[Index] := Selected;
  88. end;
  89.  
  90. end.
  91.