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 VirtualStringTree: "Beispiel" beschreibt Form.caption (https://www.delphipraxis.net/89918-virtualstringtree-beispiel-beschreibt-form-caption.html)

Graffi 8. Apr 2007 15:08


VirtualStringTree: "Beispiel" beschreibt Form.capt
 
Hallo und Frohe Ostern!

Momentan lese ich mich in VirtualStringTree ein und habe das simple Beispiel "Minimal" in meine Anwendung kopiert. Ohne jegliche Veränderung!
Problem ist nun, die Routine "InitNode" beschreibt nicht die Captions der Knoten, sondern verändert lediglich meinen Fenstertitel.

Delphi-Quellcode:
procedure TFMain.TVElemente1InitNode(Sender: TBaseVirtualTree; ParentNode,
  Node: PVirtualNode; var InitialStates: TVirtualNodeInitStates);
var
  Data: PMyRec;

begin
  with Sender do
  begin
    Data := GetNodeData(Node);
    // Construct a node caption. This event is triggered once for each node but
    // appears asynchronously, which means when the node is displayed not when it is added.
    Data.Caption := Format('Level %d, Index %d', [GetNodeLevel(Node), Node.Index]);
  end;
end;
Sehe ich den Wald vor lauter Bäumen nicht???

Gruss, Ralf

DIET3RIX 8. Apr 2007 15:15

Re: VirtualStringTree: "Beispiel" beschreibt Form.
 
Guck dir ma den Data - Typ genauer an bzw. poste den hier rein.

Oder OnGetText Ereignis

Graffi 8. Apr 2007 15:29

Re: VirtualStringTree: "Beispiel" beschreibt Form.
 
Die sind auch aus dem Beispiel kopiert:

Datatype:
Delphi-Quellcode:
type
  PMyRec = ^TMyRec;
  TMyRec = record
    Caption: WideString;
  end;
OnGetText:
Delphi-Quellcode:
procedure TFMain.TVElemente1GetText(Sender: TBaseVirtualTree;
  Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType;
  var CellText: WideString);
var
  Data: PMyRec;

begin
  // A handler for the OnGetText event is always needed as it provides the tree with the string data to display.
  // Note that we are always using WideString.
  Data := Sender.GetNodeData(Node);
  if Assigned(Data) then
    Text := Data.Caption;
end;
Selbst eine Änderung von "Caption" in z.B. "Captions" bringt nichts ... :gruebel:

Hawkeye219 8. Apr 2007 15:41

Re: VirtualStringTree: "Beispiel" beschreibt Form.
 
Hallo,

der Fehler dürfte in der vorletzten Zeile liegen:

Delphi-Quellcode:
  Data := Sender.GetNodeData(Node);
  if Assigned(Data) then
//    Text := Data.Caption;
    CellText := Data.Caption;
end;
Gruß Hawkeye

Graffi 8. Apr 2007 15:46

Re: VirtualStringTree: "Beispiel" beschreibt Form.
 
Zitat:

Zitat von Hawkeye219
der Fehler dürfte in der vorletzten Zeile liegen:
Delphi-Quellcode:
//    Text := Data.Caption;
    CellText := Data.Caption;

Stimmt genau!! Super!!

Frage mich nur, weshalb das in dem Beispiel "Minimal" so funktioniert?!

Danke und Gruss, Ralf

Hawkeye219 8. Apr 2007 16:22

Re: VirtualStringTree: "Beispiel" beschreibt Form.
 
Zitat:

Zitat von Graffi
Frage mich nur, weshalb das in dem Beispiel "Minimal" so funktioniert?!

Das ist einfach zu erklären: in früheren Version hieß der Parameter noch "Text"! Mike Lischke hat die Schnittstelle der Methode GetText geändert - möglicherweise wegen der Doppeldeutigkeit des Parameternamens. Die Demos wurden wahrscheinlich nicht aktualisiert.

Gruß Hawkeye


Alle Zeitangaben in WEZ +1. Es ist jetzt 13:30 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz