Autor Beitrag
Xenon
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 33

Win2000, XP
D6 Professionel
BeitragVerfasst: Do 03.07.03 08:15 
Hoi zemma :D

Ich arbeite mom gerade mit einem VST i hope that component know somebody? *g* Ich ärger mich grad grün und blau damit .. hab auch schon einige Tuts durchgemacht (von Fhillip Frenzel).

Jep jetzt möchte ich die Nodes irgendwie beschriften aber des haut irgendwie nicht hin hmm :? Kann mir bitte irgendwer einen Tip geben??

Ich wäre euch für jede noch so kleine Hilfestellung sehr dankbar :)

MFG XEN :wink:

_________________
Greetz Nik

Freiheit ist die Mikroskopisch kleinste Summe aus Unfreiheit!
mimi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3458

Ubuntu, Win XP
Lazarus
BeitragVerfasst: Fr 04.07.03 12:54 
gibt es sowas wie items.caption oder .text ?

_________________
MFG
Michael Springwald, "kann kein englisch...."
CenBells
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1547

Win 7
Delphi XE5 Pro
BeitragVerfasst: Fr 04.07.03 13:50 
Hallo,

dafür musst du auf das Ereignis OnGetText reagieren. Da wird dir dann der knoten geliefert, für den der Text gebraucht wird und kannst dann entsprechend drauf reagieren.

hier mal ein kleines Beispiel
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
procedure TFormGroupChoose.vVSTGroupsGetText(Sender: TBaseVirtualTree;
  Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType;
  var CellText: WideString);
var
  LGroup: TCBBelegungGruppe;
begin
  if not assigned(Node) then exit;
  LGroup := TCBBelegungGruppe(cbGetObject(Sender, Node));  // hier hole ich mir nur das objekt, was ich vorher dem node in der Data eigenschaft zugewiesen habe
  if not assigned(LGroup) then exit;
  case Column of
  0: CellText := LGroup.GruppenName; 
  1: CellText := DateToStr(LGroup.EinzugDatum);
  2: CellText := DateToStr(LGroup.AuszugDatum);
  end;
end;

Für weiter Fragen bin ich immer offen*G*

Gruß
Ken
Xenon Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 33

Win2000, XP
D6 Professionel
BeitragVerfasst: Mo 07.07.03 08:02 
Titel: VST
Hoi Ken :D

Ich hab jetzt mal ein kleines Test Progi gemacht .. des mit dem beschriften haut immer noch nicht hin :? Kannst du mir genauere Tips geben?? 8) bidde
ausblenden volle Höhe 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:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
  private
    FCaption : TStringList;
    { Private-Deklarationen }
  end;

var
  Form1: TForm1;

implementation
type
   PMyRec = ^TMyRec;
   TMyRec = Record
   Caption : WideString;
   Level: Integer;
   end;

{$R *.dfm}


// Schliesst das Programm
procedure TForm1.Button4Click(Sender: TObject);
begin
   Close;
end;


// ...
procedure TForm1.FormCreate(Sender: TObject);
begin
   VST.NodeDataSize  := SIZEOF(TMyRec);
   VST.RootNodeCount := 5;
end;


// Beschriftung der Nodes ??
procedure TForm1.VSTGetText(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; 
  TextType: TVSTTextType; var CellText: WideString);
//var
//  LGroup: TCBBelegungGruppe;
begin
//  if not assigned(Node) then exit;
//  hier hole ich mir nur das objekt, was ich vorher dem node 
//  in der Data eigenschaft zugewiesen habe
//  LGroup := TCBBelegungGruppe(cbGetObject(Sender, Node));  
//  if not assigned(LGroup) then exit;
//  case Column of
//  0: CellText := LGroup.GruppenName;
//  1: CellText := DateToStr(LGroup.EinzugDatum);
//  2: CellText := DateToStr(LGroup.AuszugDatum);
//  end;
//end;
end;

procedure TForm1.VSTFreeNode(Sender: TBaseVirtualTree; Node: PVirtualNode);
var
   Data : PMyRec;
begin

   Data := Sender.GetNodeData(Node);
   if Assigned(Data) then
      Data.Caption := '';
end;



procedure TForm1.VSTInitNode(Sender: TBaseVirtualTree; ParentNode, Node: PVirtualNode; 
  var InitialStates: TVirtualNodeInitStates);
var
   Data : PMyRec;
begin
   with Sender do
   begin
      Data := GetNodeData(Node);
      Data.Caption := Format ('Level %d, Index %d', [GetNodeLevel(Node), Node.Index]);
   end;
end;


// Löscht die bestehenden Daten im VST Cleart das VST
procedure TForm1.Button3Click(Sender: TObject);
var
   Start : Cardinal;
begin
   Screen.Cursor := crHourGlass;
   try
      Start := GetTickCount;
      VST.Clear;
      Label1.Caption := Format('Last Operation Duration: %d ms', [GetTickCount - Start]);
   finally
         Screen.Cursor := crDefault;
   end;
end;


// Button1 und Button2 in die gleiche Procedure 
// eingebunden (ADD Node + Child)
// Hinzufügen von Roots und Childs
procedure TForm1.AddButtonClick(Sender: TObject);
var
  Count: Cardinal;
  Start: Cardinal;

begin
  // Add some nodes to the treeview.
  Screen.Cursor := crHourGlass;
  with VST do
  try
    Start := GetTickCount;
    case (Sender as TButton).Tag of
      0: // add to root
        begin
          Count := StrToInt(Edit1.Text);
          RootNodeCount := RootNodeCount + Count;
        end;
      1: // add as child
        if Assigned(FocusedNode) then
        begin
          Count := StrToInt(Edit1.Text);
          ChildCount[FocusedNode] := ChildCount[FocusedNode] + Count;
          Expanded[FocusedNode] := True;
          InvalidateToBottom(FocusedNode);
        end;
    end;
    Label1.Caption := Format('Last operation duration: %d ms', [GetTickCount - Start]);
  finally
    Screen.Cursor := crDefault;
  end;
end;


// Grafik für die Nodes
procedure TForm1.VSTGetImageIndex(Sender: TBaseVirtualTree;
  Node: PVirtualNode; Kind: TVTImageKind; Column: TColumnIndex;
  var Ghosted: Boolean; var ImageIndex: Integer);
begin
   ImageIndex := Node.Index;
end;


end.


MFG XEN

_________________
Greetz Nik

Freiheit ist die Mikroskopisch kleinste Summe aus Unfreiheit!
CenBells
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1547

Win 7
Delphi XE5 Pro
BeitragVerfasst: Do 10.07.03 09:06 
Hi Xenon.

Sorry, daß ich erst so spät antworte, habe deinen beitrag nicht gesehen.
Ich schau mir den Code gerade an.

Gruß
Ken

_________________
Eine Klasse beschreibt die Struktur und das Verhalten einer Menge gleichartiger Objekte.
CenBells
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1547

Win 7
Delphi XE5 Pro
BeitragVerfasst: Fr 11.07.03 10:57 
hallo Xenon,

deine methode muss also wie folgt aussehen

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
// Beschriftung der Nodes ?? 
procedure TForm1.VSTGetText(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex;  
  TextType: TVSTTextType; var CellText: WideString); 
var
  LMyRec: PMyRec;
begin 
  if not assigned(Node) then exit;
  LMyRec := VST.GetNodeData(Node);
  if not assigned(LMyRec) then exit;
  CellText := LMyRec.Caption;
end;


Wenn du noch weitere Fragen hast, stell sie einfach *G*

Gruß
Ken

_________________
Eine Klasse beschreibt die Struktur und das Verhalten einer Menge gleichartiger Objekte.
Xenon Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 33

Win2000, XP
D6 Professionel
BeitragVerfasst: Mo 04.08.03 08:21 
Hoi Ken :D

War jetzt ne Zeit lang im Urlaub *gg* sry das ich mich erst jetzt melde!

ALSO ich hab jetzt mal versucht dein Code in mein Progi einzufügen (Copy - Paste *grins*) .. jep und ich blick da net ganz durch .. najo des funzt nicht *gg*

Gruss aus Österreich XEN

_________________
Greetz Nik

Freiheit ist die Mikroskopisch kleinste Summe aus Unfreiheit!
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Mo 04.08.03 09:11 
@Xenon:
VST arbeitet nach einem genialen, wenn auch nicht ganz einfach zu verstehenden Prinzip! Du definierst einen Record mit allen Daten die eine einzelne Node speichern soll und initialisierst im OnCreate-Ereignis die Variable NodeSize mit SizeOf(Record). Damit weiß der VST wieviel Speicehr er für eine Node reservieren muss. Über die Methode GetNodeData(<Node>) erhältst du nun den Pointer auf den Speicherbereich mit den Daten für deine Node. Und anhand dieser Daten kannst du dann eben mit deiner Node arbeiten (wie zb im OnGetText-Ereignis die richtige Beschriftung verpassen).

Das geniale an dieser Methode ist eben, dass du die Daten die pro Node gespeichert werden von dir zur Entwurfszeit individuell festgelegt werden können! VST reserviert nur den Speicher und liefert dir den Pointer darauf - was du jetzt in diesem Speicher ablegst (bzw. wie dein Record ausschaut) ist dem VST völlig egal!

Und falls du noch ein paar Verständnisprobleme im Bezug auf Pointer hast kannst du dir mal mein Pointer-Tut anschaun: www.x-spy.net/personal

PS: Grüße aus Österreich zurück! ;) 8)

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
Xenon Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 33

Win2000, XP
D6 Professionel
BeitragVerfasst: Mo 04.08.03 09:44 
Hoi Motzi :D

Thänx für deine schnelle antwort :)

Ich werd mir mal dein Tut ansehn, danke für die Addi .. ich hoff dann check ich ein bisschen mehr *gg*

Hoi und danke ausm Gsiberg Nik 8)

_________________
Greetz Nik

Freiheit ist die Mikroskopisch kleinste Summe aus Unfreiheit!