我正在尝试将项目从 D6 移动到 D-XE3。使用 VirtualStringTree 5.10 版本在 OnSaveNode 和 OnLoadEvents 中保存和加载树数据时出现垃圾。我可能没有正确处理 Unicode,但我可能还有其他一些无知:
procedure TfMain.vstGridSaveNode(Sender: TBaseVirtualTree; Node: PVirtualNode;
Stream: TStream);
var
Data: PStkData;
begin
Data := Sender.GetNodeData(Node);
// Owned: boolean;
Stream.Write(Data.Owned, SizeOf(boolean) );
// Symbol: string;
Stream.Write(PChar(Data.Symbol)^, Length(Data.Symbol) * SizeOf(Char));
// AvgTarget: currency;
//Stream.Write(Data.AvgTarget, SizeOf(currency));
// PE: double;
Stream.Write(Data.PE, SizeOf(double));
end;
procedure TfMain.vstGridLoadNode(Sender: TBaseVirtualTree; Node: PVirtualNode;
Stream: TStream);
var
Data: PStkData;
begin
Data := Sender.GetNodeData(Node);
//Owned: boolean;
Stream.Read(Data.Owned, SizeOf(boolean));
//Symbol: string;
Stream.Read(PChar(Data.Symbol)^, Length(Data.Symbol) * SizeOf(Char));
//AvgTarget: currency;
Stream.Read(Data.AvgTarget, SizeOf(currency));
//PE: double;
Stream.Read(Data.PE, SizeOf(double));
end;
谢谢你的帮助。