Hallo,
danke für den Hinweis aber das hatte ich auch schon probiert und es will einfach nicht gehen.
Delphi-Quellcode:
unit ColorListBox;
interface
uses
SysUtils, Classes, Controls, StdCtrls, Graphics, Windows, Messages;
type
MyColorListBox =
class(TListBox)
private
{ Private-Deklarationen }
FColor : TColor;
procedure SetColor(Value:TColor);
protected
{ Protected-Deklarationen }
public
{ Public-Deklarationen }
constructor Create(AOwner:TComponent);
override;
destructor Destroy;
override;
procedure DrawItem(
Index: Integer; Rect: TRect;
State: TOwnerDrawState);
override;
published
{ Published-Deklarationen }
property DrawColor : TColor
read FColor
write SetColor;
end;
procedure Register;
{ ----------------------------------------------------------------------------- }
implementation
{ ----------------------------------------------------------------------------- }
procedure Register;
begin
RegisterComponents('
Beispiele', [MyColorListBox]);
end;
{ ----------------------------------------------------------------------------- }
{ ColorListBox }
{ ----------------------------------------------------------------------------- }
constructor MyColorListBox.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
Width := 100;
Height := 100;
end;
{ ----------------------------------------------------------------------------- }
destructor MyColorListBox.Destroy;
begin
inherited Destroy;
end;
{ ----------------------------------------------------------------------------- }
procedure MyColorListBox.DrawItem(
Index: Integer; Rect: TRect;
State: TOwnerDrawState);
begin
inherited;
if ItemIndex = -1
then exit;
Canvas.Brush.Color := FColor;
Canvas.FillRect(Rect);
Canvas.TextOut(Rect.Left,Rect.Top, Items[
Index]);
end;
{ ----------------------------------------------------------------------------- }
procedure MyColorListBox.SetColor(Value: TColor);
begin
FColor := Value;
end;
{ ----------------------------------------------------------------------------- }
end.
jedesmal wenn ich ein element markiere habe ich ein Blauen Rahmen obwohl ich bei DrawColor rot eingestellt habe.Hast du eine Ahnung Jens?
Thx Alex