home *** CD-ROM | disk | FTP | other *** search
/ Delphi 2.0 - Programmer's Utilities Power Pack / Delphi 2.0 Programmer's Utilities Power Pack.iso / m_to_r / picklist / od_test.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-09-15  |  1.9 KB  |  75 lines

  1. unit Od_test;
  2.  
  3. {Copyright 1995 by Robert Fabiszak
  4.   OD_TEST - Sample program to demonstate the usage and benefits
  5.   of the PICKLIST control. It fills the listbox with with a
  6.   poem; you'd never guess that one of my degrees is in English!
  7.   Poem copyright by the Executors of the Estate of Robert Graves;
  8.   I hope I don't get in trouble by quoting it!
  9.  
  10.   Free unrestricted use granted provided this copyright notice
  11.   is maintained.
  12.  
  13.   PICKLIST is an enhanced list box control for Borland's Delphi
  14.   product. Version 1.0. June, 1995}
  15.  
  16. interface
  17.  
  18. uses WinTypes, WinProcs, Classes, Graphics, Forms, Controls, Buttons,
  19.   StdCtrls, Picklist;
  20.  
  21. type
  22.   TPoemDialog = class(TForm)
  23.     OKBtn: TBitBtn;
  24.     CancelBtn: TBitBtn;
  25.     GroupBox1: TGroupBox;
  26.     LBPoem: TPickList;
  27.     Label1: TLabel;
  28.     LineLabel: TLabel;
  29.     procedure LBPoemDrawItem(Control: TWinControl; Index: Integer;
  30.       Rect: TRect; State: TOwnerDrawState);
  31.     procedure LBPoemChange(Sender: TObject);
  32.   private
  33.     { Private declarations }
  34.   public
  35.     { Public declarations }
  36.   end;
  37.  
  38. var
  39.   PoemDialog: TPoemDialog;
  40.  
  41. implementation
  42.  
  43. uses sysutils;
  44.  
  45. {$R *.DFM}
  46.  
  47. procedure TPoemDialog.LBPoemDrawItem(Control: TWinControl;
  48.   Index: Integer; Rect: TRect; State: TOwnerDrawState);
  49. const
  50.   ColorArray: array[0..7] of TColor = (clBlack, clBlue, clDkGray,
  51.     clGreen, clMaroon, clNavy, clPurple, clRed);
  52. begin
  53.   with LBPoem.Canvas do
  54.   begin
  55.     Brush.Color := clWindow;
  56.     FillRect(Rect);
  57.     Font.Color := ColorArray[Index];
  58.     if odSelected in State then
  59.       Font.Style := Font.Style + [fsBold]
  60.     else
  61.       Font.Style := Font.Style - [fsBold];
  62.     TextOut(Rect.Left + 2, Rect.Top, LBPoem.Items[Index]);
  63.   end;
  64. end;
  65.  
  66. procedure TPoemDialog.LBPoemChange(Sender: TObject);
  67. begin
  68.   if LBPoem.ItemIndex >= 0 then
  69.     LineLabel.Caption := 'Selected line ' + IntToStr(LBPoem.ItemIndex)
  70.   else
  71.     LineLabel.Caption := '';
  72. end;
  73.  
  74. end.
  75.