home *** CD-ROM | disk | FTP | other *** search
- unit Od_test;
-
- {Copyright 1995 by Robert Fabiszak
- OD_TEST - Sample program to demonstate the usage and benefits
- of the PICKLIST control. It fills the listbox with with a
- poem; you'd never guess that one of my degrees is in English!
- Poem copyright by the Executors of the Estate of Robert Graves;
- I hope I don't get in trouble by quoting it!
-
- Free unrestricted use granted provided this copyright notice
- is maintained.
-
- PICKLIST is an enhanced list box control for Borland's Delphi
- product. Version 1.0. June, 1995}
-
- interface
-
- uses WinTypes, WinProcs, Classes, Graphics, Forms, Controls, Buttons,
- StdCtrls, Picklist;
-
- type
- TPoemDialog = class(TForm)
- OKBtn: TBitBtn;
- CancelBtn: TBitBtn;
- GroupBox1: TGroupBox;
- LBPoem: TPickList;
- Label1: TLabel;
- LineLabel: TLabel;
- procedure LBPoemDrawItem(Control: TWinControl; Index: Integer;
- Rect: TRect; State: TOwnerDrawState);
- procedure LBPoemChange(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
-
- var
- PoemDialog: TPoemDialog;
-
- implementation
-
- uses sysutils;
-
- {$R *.DFM}
-
- procedure TPoemDialog.LBPoemDrawItem(Control: TWinControl;
- Index: Integer; Rect: TRect; State: TOwnerDrawState);
- const
- ColorArray: array[0..7] of TColor = (clBlack, clBlue, clDkGray,
- clGreen, clMaroon, clNavy, clPurple, clRed);
- begin
- with LBPoem.Canvas do
- begin
- Brush.Color := clWindow;
- FillRect(Rect);
- Font.Color := ColorArray[Index];
- if odSelected in State then
- Font.Style := Font.Style + [fsBold]
- else
- Font.Style := Font.Style - [fsBold];
- TextOut(Rect.Left + 2, Rect.Top, LBPoem.Items[Index]);
- end;
- end;
-
- procedure TPoemDialog.LBPoemChange(Sender: TObject);
- begin
- if LBPoem.ItemIndex >= 0 then
- LineLabel.Caption := 'Selected line ' + IntToStr(LBPoem.ItemIndex)
- else
- LineLabel.Caption := '';
- end;
-
- end.
-