![]() |
Re: .... nochmals VirtualStringTree
wie waere es mit sowas:
Delphi-Quellcode:
vst.nodedatasize:=sizeof(tobject)
type tmonat = class a,b: string; c: integer; end; twoche = class d: integer; end; tprojekt = class name, usw: string; end; monat:=tmonat.create(); node:=vst.addchild(nil, monat); woche:=twoche.create(); node:=vst.addchild(node, woche); proj:=tprojekt.Create(); vst.addchild(node, proj); procedure vst.onfreenode tobject(vst.getnodedata(node)).free; procedure vst.ongettext; obj:=tobject(vst.getnodedata(node)); if obj is tmonat then with tmonat(obj) do case column of 0: celltext:=a; 1: celltext:=b; end; if obj is twoche then with twoche (obj) do case column of 0: celltext:=d; end; if obj is tproject then with tproject(obj) do case column of 0: celltext:=name; 1: celltext:=usw; end; |
Re: .... nochmals VirtualStringTree
Sodala, funktioniert eigentlich schon ganz gut, bis auf das "füllen" der ChildNodes.
Hier mal der Code
Delphi-Quellcode:
type
PVSTData = ^TVSTData; TVSTData = record monat: string; projektnr: string; end; procedure TFrmMain.InitForm; var count : integer; strMonths : string; actMonth,actYear,foo : word; result : pmysql_res; row : pmysql_row; rowCount : my_ulonglong; rootNode,childNode : PVirtualNode; rootData,childData : PVSTData; begin . . . StringTree.BeginUpdate; StringTree.NodeDataSize := SizeOf(PVSTData); for count := 1 to CMONTHS do begin rootNode := StringTree.AddChild(nil); rootData := StringTree.GetNodeData(rootNode); rootData^.monat := CboxMonth.Items.Strings[count - 1]; Query('SELECT p_nummer FROM projekte WHERE (p_monat = '+inttostr(count)+')'); result := mysql_store_result(SqlHnd); rowCount := mysql_num_rows(result); while (rowCount > 0) do begin row := mysql_fetch_row(result); childNode := StringTree.AddChild(rootNode); childData := StringTree.GetNodeData(childNode); --> childData^.projektnr := row[0]; //showmessage(row[0]); dec(rowCount); end; mysql_free_result(result); end; StringTree.EndUpdate; end; Wenn die Zeile mit Pfeil auskommentiert wird dann funktioniert das ganze wunderbar. Es werden alle 12 Monate angelegt und für jeden Monat wird auch die richtige Anzahl an ChildNodes entsprechend den Projekten in dem jeweiligen Monat angelegt. Nur wenn ich die Projektnummer auch anzeigen möchte in dem VirtualStringTree, dann gibts eine AccessViolation. An dem MySQL Ergebnis liegt es nicht, denn die Nummer kann ich mir mit showmessage anzeigen lassen. Ich habe auch mal versucht in den gleichen Record zu schreiben (rootData), hat auch nicht funktioniert. Marcus |
Re: .... nochmals VirtualStringTree
Zitat:
wie sieht denn dein ongettext aus? Gruß Ken |
Re: .... nochmals VirtualStringTree
Hallo, der geht natürlich auch in die Hose.
Delphi-Quellcode:
procedure TFrmMain.StringTreeGetText(Sender: TBaseVirtualTree;
Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType; var CellText: WideString); var Data : PVSTData; begin Data := Sender.GetNodeData(Node); if Node.Parent = Sender.RootNode then CellText := Data^.monat else CellText := Data^.projektnr; //CellText := 'test'; end; |
Re: .... nochmals VirtualStringTree
imho liegt das an pmysql_row.
das p deutet auf einen zeiger. probier mal
Delphi-Quellcode:
var s: string;
s:=strpas(row[0]) childData^.projektnr := s; |
Re: .... nochmals VirtualStringTree
ich glaub, das es es eher an
Delphi-Quellcode:
liegt, da du VST die allokierung (man wie schreibt man das auf Deutsch ?) des Speichers an VST übergibst.
StringTree.NodeDataSize := SizeOf(PVSTData);
und die sagst im ja nur die größe des Pointers ! probier mal
Delphi-Quellcode:
gruss
StringTree.NodeDataSize := SizeOf(TVSTData);
hans |
Re: .... nochmals VirtualStringTree
Tatsache,
funktioniert wunderbar! Vielen Dank Marcus |
Alle Zeitangaben in WEZ +1. Es ist jetzt 17:04 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-2025 by Thomas Breitkreuz