Delphi-PRAXiS
Seite 3 von 3     123   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi mehrzeilige listbox-einträge (https://www.delphipraxis.net/89945-mehrzeilige-listbox-eintraege.html)

maddins 17. Apr 2007 21:12

Re: mehrzeilige listbox-einträge
 
oops! ich war nur schlampig...

hab doch die position zum zeichnen mit dem index errechnet und nich mit den eigenschaften von >>rect<<...

also ich denke, damit werd ich jetz erstmal klarkommen und nen bisschen experimentieren.

vielen dank nochmal für die hilfe. falls ich später noch fragen hab, werd ich die hier posten, ich wollt ja noch n paar klickereignisse implementieren und auch kleine bildchen zeichnen. aber davon hab ich ja hier schon beispiele in hülle und fülle gesehn.

bis dann + grüße
maddins

LinuxFan 6. Okt 2008 22:58

Re: mehrzeilige listbox-einträge
 
Hallo,

wo kommt die Funktion "Dispose(...)" rein?

hoika 7. Okt 2008 02:47

Re: mehrzeilige listbox-einträge
 
Hallo,

warum so kompliziert,
nimm einen TListView, da musst du gar nichts machen.

Delphi-Quellcode:
ListItem:= ListView.Items.Add;
ListItem.Caption:= 'Spalte 1';
ListItem.SubItems.Add('Spalte2');

Update:
Habe gerade "Bildchen zeichnen" gelesen
-> TVirtualTreeView, auch wenn der Anfang etwas kompliziert ist,
aber dafür gibt es Tutorials (Such-Funktion)


Heiko

LinuxFan 10. Okt 2008 18:32

Re: mehrzeilige listbox-einträge
 
Zitat:

Zitat von hoika
Hallo,

warum so kompliziert,
nimm einen TListView, da musst du gar nichts machen.

Delphi-Quellcode:
ListItem:= ListView.Items.Add;
ListItem.Caption:= 'Spalte 1';
ListItem.SubItems.Add('Spalte2');

Hier geht es um mehrZEILIGE ListBoxes. Nicht um mehrspaltige.

Für alle die es interessiert:
Delphi-Quellcode:
type
  TCodeInsightItem = record
                       ciType: string[255];
                       ciKey: string[255];
                       ciAttri: string[255];
                       ciReturn: string[255];
                       ciDesc: string[255];
                     end;

type
  PCodeInsightItem = ^TCodeInsightItem;

...........

procedure X ...;
var
  ciEntry: TCodeInsightItem;
  ciEntryP: PCodeInsightItem;
begin
  for i := 0 to lbxCodeInsight.Items.Count - 1 do
  begin
    ciEntryP := PCodeInsightItem(lbxCodeInsight.Items.Objects[i]);
    Dispose(ciEntryP);
  end;
  lbxCodeInsight.Items.Clear;
  for i := 0 to intBuffer - 1 do
  begin
    ... Definition von ciEntry ...
    New(ciEntryP);
    ciEntryP^.ciType := ciEntry.ciType;
    ciEntryP^.ciKey := ciEntry.ciKey;
    ciEntryP^.ciAttri := ciEntry.ciAttri;
    ciEntryP^.ciReturn := ciEntry.ciReturn;
    ciEntryP^.ciDesc := ciEntry.ciDesc;

    lbxCodeInsight.Items.AddObject(ciEntryP^.ciKey, TObject(ciEntryP));
  end;
end;

procedure TfrmMain.lbxCodeInsightDrawItem(Control: TWinControl; Index: Integer;
  Rect: TRect; State: TOwnerDrawState);
var
  Entry: PCodeInsightItem;
  ciKeyWidth, ciAttriWidth: Integer;
begin
     Entry := PCodeInsightItem(Items.Objects[Index]);
     if ItemIndex <> Index then
       if Index mod 2 = 0 then Canvas.Brush.Color := $00FDF7EE else Canvas.Brush.Color := clWhite;
     Canvas.FillRect(Rect);
     Canvas.TextOut(Rect.Left+1, Rect.Top+1, Entry^.ciType);
     Canvas.Font.Style := [fsBold];
     Canvas.TextOut(Rect.Left+60, Rect.Top+1, Entry^.ciKey);
     ciKeyWidth := Canvas.TextWidth(Entry^.ciKey);
     Canvas.Font.Style := [];
     Canvas.TextOut(Rect.Left+60+ciKeyWidth, Rect.Top+1, ' (' + Entry^.ciAttri + ')');
     ciAttriWidth := Canvas.TextWidth(' (' + Entry^.ciAttri + ')');
     if Entry^.ciReturn <> '' then Canvas.TextOut(Rect.Left+60+ciKeyWidth+ciAttriWidth, Rect.Top+1, ' : ' + Entry^.ciReturn);
     Canvas.Font.Style := [fsBold];
     Canvas.Font.Size := 8;
     Canvas.TextOut(Rect.Left+5, Rect.Top+18, Entry^.ciDesc);
   end;
end;
http://home.viathinksoft.de/victor/d...ne_listbox.jpg

Sunlight7 10. Okt 2008 18:50

Re: mehrzeilige listbox-einträge
 
Zitat:

Zitat von LinuxFan
Hallo,

wo kommt die Funktion "Dispose(...)" rein?

Also Dispose rufst Du überall auf, wenn einzelne oder mehrere/alle Objecte aus der Liste entfernt werden.
  • .Delete(x);
  • .Clear;
  • und im Destructor
  • Genau genommen auch beim Zuweisen von Items.Text
Am einfachsten ist es, Dir eine neue Klasse abzuleiten, denn da kannst Du es einfach überschreiben und brauchst Dich im eigentlichem QT nicht mehr drum zu kümmern.

MfG, Sun

hoika 11. Okt 2008 08:23

Re: mehrzeilige listbox-einträge
 
Hm,

oha, mehrzeilig.

virtual treeview + wordrwap


Heiko


Alle Zeitangaben in WEZ +1. Es ist jetzt 03:00 Uhr.
Seite 3 von 3     123   

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-2025 by Thomas Breitkreuz