AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

ListBox-Problem

Ein Thema von Tommy1988 · begonnen am 4. Aug 2007 · letzter Beitrag vom 4. Aug 2007
Antwort Antwort
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
Klaus01

Registriert seit: 30. Nov 2005
Ort: München
5.755 Beiträge
 
Delphi 10.4 Sydney
 
#2

Re: ListBox-Problem

  Alt 4. Aug 2007, 16:36
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
Klaus
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 22:58 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz