![]() |
ListBox-Problem
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:
123 und Ddie zeit werden ins ListBox jeder ListBoxeintrag hat die selbe Zeit in der 2. Zeile stehen..
procedure TForm1.Edit1Change(Sender: TObject);
var i: Integer; begin ListBox2.Items.Add('123'); // 1. Zeile 123, Zweite Zeile Time end; |
Re: ListBox-Problem
Ich denke das DrawItem wird bei jedem Neuzeichnen der Listbox ausgeführt.
Da das recht schnell geht, ist in jeder Zeile die gleiche Zeit zu sehen. Setze einmal eine Breakpoint in die Routine und dann wirst Du sehen wie oft sie ausgeführt wird. Es ist öfter als bei jedem Items.add. Grüße Klaus |
Alle Zeitangaben in WEZ +1. Es ist jetzt 10:18 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz