Autor Beitrag
sahib
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 117

Win 2000 SP4+
Delphi 5 Prof.
BeitragVerfasst: So 17.07.05 01:15 
Hallo.

Wie kann ich in einem TreeView die ganze Zeile markieren? Es sieht so unschön aus, wenn der Balken gleich hinter dem Text aufhört. Gibt es da einen (versteckten) Befehl, oder muss ich wirklich alles selber zeichnen (Linien, Schrift, Bilder)?

Danke und viele Grüße,
Christian
Harry M.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 754

Win 2000, XP
D2005
BeitragVerfasst: So 17.07.05 09:26 
Du musst die breite des letzten Columms der Breite des Treeviews anpassen. Etwa im Resize-Ereignis.

_________________
Gruß Harry
Et spes me per dies sine te ducat et amor me ferat, si dolor spem tollit.
sahib Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 117

Win 2000 SP4+
Delphi 5 Prof.
BeitragVerfasst: So 17.07.05 10:13 
Hallo Harry.

Ohne es überprüft zu haben, denke ich, dass ich damit nicht weiterkomme. Ich wollte nicht sie Spaltenbreite an die Einträge anpassen, sondern den Auswahlbalken bis zum (rechten) Rand erweitern.

Christian
TND:Ariakas
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 18

WinXP, Debian
D7 PE, MS VS 2k5 (Just for C/C++/C#)
BeitragVerfasst: So 17.07.05 10:38 
Schau dir mal das Ereigniss OnCustomDrawItem an, damit kann mans hinkriegen.

_________________
Error!
Reality.sys is corrupt. Smash head on keyboard to restart universe!!
Harry M.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 754

Win 2000, XP
D2005
BeitragVerfasst: So 17.07.05 10:55 
user profile iconsahib hat folgendes geschrieben:

Ohne es überprüft zu haben...
Christian


Vielleicht machst Du das erstmal! :motz:

_________________
Gruß Harry
Et spes me per dies sine te ducat et amor me ferat, si dolor spem tollit.
sahib Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 117

Win 2000 SP4+
Delphi 5 Prof.
BeitragVerfasst: So 17.07.05 11:35 
Hi.

Harry M. hat folgendes geschrieben:
Vielleicht machst Du das erstmal

Da muss ich mich jetzt mal klar weigern ;) Das wird doch nicht klappen! Zumindest die TreeView unter Delphi5 stellt den Auswahlbalken nicht bis zum (rechten) Rand da. Und wenn ich diesen Rand nun noch weiter entferne... ;) Ich denke, Du hast ListView statt TreeView gelesen?

TND:Ariakas hat folgendes geschrieben:
Schau dir mal das Ereigniss OnCustomDrawItem an, damit kann mans hinkriegen.

Natürlich kann man das, so habe ich es auch bisher gemacht. Aber wenn ich lediglich den Balken ganz ausgedehnt haben möchte, sehe ich nicht ein, dass ich mich auch noch um Schrift und Bildchen kümmern soll. Das läuft zwar, sieht aber nicht so gut aus. Zum Beispiel weiß ich nicht, welche Farbe diese Linien im Tree habe. Und manchesmal gibt es noch kleinere Graphikfehler. Aber das ist eine Sache meiner eigenen Unzulänglichkeit ;)

Christian
Harry M.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 754

Win 2000, XP
D2005
BeitragVerfasst: So 17.07.05 12:02 
Ups Du könnstet recht haben. Sorry. :oops:

_________________
Gruß Harry
Et spes me per dies sine te ducat et amor me ferat, si dolor spem tollit.
sahib Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 117

Win 2000 SP4+
Delphi 5 Prof.
BeitragVerfasst: So 17.07.05 13:40 
Okay, dann poste ich mal meine Lösung. Musste doch nicht alles zeichnen. Vielleicht kann man da noch etwas machen... Soweit klappt das jetzt.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
procedure TfrmSettings.tvExportCustomDrawItem(Sender: TCustomTreeView;
  Node: TTreeNode; State: TCustomDrawState; var DefaultDraw: Boolean);
var
  ARect: TRect;
begin
  with tvExport.Canvas do
  begin
    ARect := Node.DisplayRect(False);
    if Node.Parent = nil then
      Font.Style := [fsBold]
    else
      Font.Style := [];

    if cdsSelected in State then begin
      Font.Color := clHighLightText;
      Brush.Color := clHighLight
    end
    else begin
      Font.Color := clBlack;
      Brush.Color := clBtnFace
    end;
    FillRect(ARect);
    TextOut(ARect.Left, ARect.Top, Node.Text)
  end
end;


Christian