unit Unit3;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TListbox=Class(StdCtrls.TListBox)
procedure CNDrawItem(
var Message: TWMDrawItem);
message CN_DRAWITEM;
End;
TForm3 =
class(TForm)
ListBox1: TListBox;
procedure FormCreate(Sender: TObject);
procedure ListBox1DrawItem(Control: TWinControl;
Index: Integer; Rect: TRect; State: TOwnerDrawState);
private
Fcanvas:TCanvas;
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form3: TForm3;
implementation
{$R *.dfm}
procedure TForm3.FormCreate(Sender: TObject);
var
i:Integer;
begin
Fcanvas := TCanvas.Create;
for I := 1
to 10
do
Listbox1.Items.Add('
testdfdsf');
end;
procedure TForm3.ListBox1DrawItem(Control: TWinControl;
Index: Integer; Rect: TRect; State: TOwnerDrawState);
begin
with TListBox(Control).Canvas
do
begin
if odSelected
in State
then Brush.Color := clLime
else Brush.Color := $EEEEEE;
Fillrect(rect);
Textout(rect.Left,rect.Top,TListBox(Control).Items[
Index]);
end;
end;
{ TListbox }
procedure TListbox.CNDrawItem(
var Message: TWMDrawItem);
var
w:TOwnerDrawState;
begin
w := TOwnerDrawState(LoWord(
Message.DrawItemStruct^.itemState));
Exclude(w , odFocused);
Message.DrawItemStruct^.itemState :=
Message.DrawItemStruct^.itemState
and ( $FFFF0000 + Word(w));
inherited;
end;
end.