Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Delphi TreeView.CustomDrawItem verschiedene höhen (https://www.delphipraxis.net/157361-treeview-customdrawitem-verschiedene-hoehen.html)

Cyberaxx 9. Jan 2011 16:56


TreeView.CustomDrawItem verschiedene höhen
 
Hallo

Bisher bin ich hier und auch durch Google nicht fündig geworden was dies angeht.
Ich nutze eine TreeView als Kontaktliste. Diese beinhaltet 2 Level. Einmal zur Darstellung
der Gruppen und dann in den Gruppen die Kontakte.

das ich die Zeilenhöhe anpassen kann mit
Delphi-Quellcode:
TTreeView.Perform(TVM_SETITEMHEIGHT, 32, 0);
weiß ich wohl und nutze es auch bisher aber wie bekomme ich es hin das ich den Nodes
beim Zeichnen verschiedene Höhen geben kann?

Meine Zeichenmethode schaut bisher so aus
Delphi-Quellcode:
procedure TContactListTree.CustomDrawItem(Sender: TCustomTreeView;
  Node: TTreeNode; State: TCustomDrawState; var DefaultDraw: Boolean);
  var
    NodeRect: TRect;
    PictureRect: TRect;
    Group: TGroup;
    Contact: TContact;
begin
  DefaultDraw := False;

  NodeRect := Node.DisplayRect(False);
  PictureRect := Node.DisplayRect(False);
  if cdsSelected in State then begin
    FList.Canvas.Pen.Color := ITEM_SELECTED_COLOR;
    FList.Canvas.Brush.Color := ITEM_SELECTED_COLOR;
    FList.Canvas.Brush.Style := bsSolid;
    //FList.Canvas.RoundRect(NodeRect.Left, NodeRect.Top, NodeRect.Right, NodeRect.Bottom, 8, 8);
  end
  else if (cdsHot in state) and (not (cdsFocused in state)) then begin
    FList.Canvas.Pen.Color := ITEM_HOVER_COLOR;
    FList.Canvas.Brush.Color := ITEM_HOVER_COLOR;
    FList.Canvas.Brush.Style := bsSolid;
    //FList.Canvas.RoundRect(NodeRect.Left, NodeRect.Top, NodeRect.Right, NodeRect.Bottom, 8, 8);
  end
  else
    FList.Canvas.FillRect(NodeRect);

  FList.Canvas.FillRect(NodeRect);

  // Node Level 0 = Gruppen Node
  // Node Level 1 = Kontakt Node
  if Node.Level = 0 then begin
    Group := Node.Data;

    FList.Canvas.Font.Color := clBlack;
    FList.Canvas.Font.Name := 'Arial';
    FList.Canvas.Font.Size := 12;
    FList.Canvas.Font.Style := [fsBold];
    NodeRect.Left := NodeRect.Left + 2;
    NodeRect.Top := NodeRect.Top + 6;
    FList.Canvas.TextOut(NodeRect.Left, NodeRect.Top, Format('%s %d/%d', [Group.Name, Group.Count, Group.Count]));
  end
  else if Node.Level = 1 then begin
    Contact := Node.Data;

    FList.Canvas.Font.Color := clBlack;
    FList.Canvas.Font.Name := 'Arial';
    FList.Canvas.Font.Size := 12;
    FList.Canvas.Font.Style := [fsBold];
    NodeRect.Left := NodeRect.Left + 20;
    NodeRect.Top := NodeRect.Top + 2;
    FList.Canvas.TextOut(NodeRect.Left, NodeRect.Top, Contact.Name);

    FList.Canvas.Refresh;
    FList.Canvas.Font.Color := $002492FF;
    FList.Canvas.Font.Name := 'Arial';
    FList.Canvas.Font.Size := 8;
    FList.Canvas.Font.Style := [];
    NodeRect.Top := NodeRect.Top + 16;
    //FList.Canvas.TextOut(NodeRect.Left, NodeRect.Top, Contact.OnlineStateMsg);
    DrawText(FList.Canvas.Handle, PChar(Contact.OnlineStateMsg), length(Contact.OnlineStateMsg), NodeRect, 0);
  end;
end;
Bisher schaut es nicht gerade toll aus wenn die Gruppe nur einen Namen enthällt aber 5 mal so groß
ist wie sie eigentlich sein müsste.

Schonmal danke für die Antworten, wenn jemand eine weiß.

Gruß

Cyberaxx

Cyberaxx 11. Jan 2011 15:18

AW: TreeView.CustomDrawItem verschiedene höhen
 
Ich bin eigentlich nicht derjenige der überhaupt und wenn gerne pusht aber ich selber komme leider immernoch zu keiner Lösung.
Dachte mir zuerst ich könnte das DisplayRect verändern doch dies bringt auch keine Veränderung.

So sollte es mal aussehen
http://dsnweb.de/upload/Delphi-PRAXi...1_14-50-20.png

so schaut es aus wenn ich das DisplayRect ändere. Was aber leider nicht dazu führt das die Node kleiner ist
http://dsnweb.de/upload/Contactlist%...1_15-10-29.png

So schaut es "Normal" aus
http://dsnweb.de/upload/Contactlist%...1_15-10-59.png

Cyberaxx 20. Jan 2011 14:48

AW: TreeView.CustomDrawItem verschiedene höhen
 
Ich mag das Thema ungerne wieder nach oben schleppen aber es gibt hierzu immernoch keine Lösung.
Es muss doch irgendwie möglich sein die Höhe der Nodes anzupassen.


Alle Zeitangaben in WEZ +1. Es ist jetzt 04:15 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