Autor Beitrag
Rylon
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 38



BeitragVerfasst: Sa 19.08.06 21:48 
Treeview Selektion färben

Ich würde gerne bei einem Treeview die Selektion färben. Sowol wenn der Treeview aktiv ist, als auch wenn er inaktiv ist (HideSelektion=false setzen, dann sieht man die Selektion auch wenn man z.B. gerade was in ein Memo auf der selben Form schreibt).

Grund: Es ist unschön, wenn man 2 Treeviews hat und der eine den Inhalt von dem selektierten Item des anderen anzeigen soll und man nicht weiß, welches item in inaktive Treeview Selektiert ist. Das lässt sich nun mit HideSelektion:=false beheben. Leider ist diese Lösung optisch nicht einwandfrei. Deshalb möchte ich den User gerne die Selektionsfarbe wählen lassen (sowol aktive, als auch inaktive selektion)

Jemand Vorschläge? -> HAbe ausgiebig im Forum gesucht - nichts passendes gefunden

Danke schon im Vorraus

Grüße Rylon t.H.D.
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Sa 19.08.06 21:50 
Neue Komponente von TTReeview ableiten und selber zeichnen?!?

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Rylon Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 38



BeitragVerfasst: Sa 19.08.06 21:55 
Titel: OnCustomDraw/Item
Ich hatte eher an ein Zeichnen im OnCustomDraw/Item event gedacht -> jemand ein Vorschlag?

Grüße Rylon t.H.D.

PS: Danke Marco D. für die extrem schnelle Antwort ;-)
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Sa 19.08.06 22:03 
Habe ich dich so richtig verstanden: Der User soll die Farbe der Markierung des ausgewählten Eintrags wählen können?

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Rylon Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 38



BeitragVerfasst: Sa 19.08.06 22:08 
Titel: Ja
Ja:

"Deshalb möchte ich den User gerne die Selektionsfarbe wählen lassen" -> d.h. nich hardcoded -> sondern changeable ;-)

Greez Rylon t.H.D.
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Sa 19.08.06 22:13 
Gibt es beim Treeview so etwas wie einen Itemindex?

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Rylon Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 38



BeitragVerfasst: Sa 19.08.06 22:22 
Titel: Was meinst Du damit?
Was meinst Du damit?

-> Eindeutige Erkennung eines Nodes? : Ja: ItemId
-> oder was meinst Du?

Siehe: users.iafrica.com/d/...eeView/TreeView.html

Grüße Rylon t.H.D.
Rylon Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 38



BeitragVerfasst: So 20.08.06 04:40 
Titel: Hat sich erledigt
Hat sich erledigt: Hier mein Code:

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure TfMain.tvCategoryCustomDrawItem(Sender: TCustomTreeView;
  Node: TTreeNode; State: TCustomDrawState; var DefaultDraw: Boolean);
begin

  //Color Selection
  if tvCategory.SelectionCount>0 then
    if tvCategory.Selected=Node then tvCategory.Canvas.Brush.Color:=selectcolor else tvCategory.Canvas.Brush.Color:=normalcolor;

end;


wobei

ausblenden Quelltext
1:
2:
tvCategory:TTreeview;
normalcolor,selectcolor:Integer/TColor


sind.

Werf ein Treeview auf die form und schreib den oben Zitierten Code in das OnCustomDrawItem Ereignis.

normalcolor und selectcolor müssen keine Variablen sein, sondern können Statisch zugewiesenw erden:

ausblenden Quelltext
1:
tvCategory.Canvas.Brush.Color:=12345;					


bzw.

ausblenden Quelltext
1:
tvCategory.Canvas.Brush.Color:=clred;					


Hoffe das hilft irgendjemand mal weiter ;-)

Grüße Rylon t.H.D.

PS: Fragen: PM Me