Thema: Delphi ListBox-Problem

Einzelnen Beitrag anzeigen

Tommy1988
(Gast)

n/a Beiträge
 
#1

ListBox-Problem

  Alt 4. Aug 2007, 16:08
Hallo, folgenden COde habe ich aus dem BassPLayer:

Delphi-Quellcode:
 
procedure TForm1.FormCreate(Sender: TObject);
begin
 ListBox2.DoubleBuffered := TRUE;
  ListBox2.Style := lbOwnerDrawVariable;
  ListBox2.ItemHeight := (ListBox1.Canvas.Font.Height * -1) * 3;
end;

Und


Delphi-Quellcode:
procedure TForm1.ListBox2DrawItem(Control: TWinControl; Index: Integer;
  Rect: TRect; State: TOwnerDrawState);
var
  oldBrushColor, oldFontColor: TColor;
begin
  if TListBox(Control).Items.Count > -1 then
  with Control as TListBox do
  begin
    Canvas.FillRect(Rect);

    if (Tag > -1) and (Tag = Index) then
    begin
      oldBrushColor := Canvas.Brush.Color;
      Canvas.Brush.Color := clLime;
      Canvas.FillRect(Classes.Rect(rect.left,
      rect.top+1, rect.left+3, rect.Bottom-1));
      Canvas.Brush.Color := oldBrushColor;
    end;

    Canvas.Font.Style := Canvas.Font.Style + [fsBold];

    Canvas.Font.Style := Canvas.Font.Style -
    [fsBold] + [fsItalic];

    Canvas.Font.Name := 'arial';
    Canvas.Font.Size := 7;

    Canvas.Font.Color := clGrayText;
    Canvas.TextOut(
      22,
      Rect.Bottom - (Canvas.Font.Height * - 1) - 4,
     TimeToStr(Now));
  end;
end;
Delphi-Quellcode:
procedure TForm1.Edit1Change(Sender: TObject);
var
i: Integer;
begin
  ListBox2.Items.Add('123'); // 1. Zeile 123, Zweite Zeile Time
end;
123 und Ddie zeit werden ins ListBox jeder ListBoxeintrag hat die selbe Zeit in der 2. Zeile stehen..
  Mit Zitat antworten Zitat