Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit uMain;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, VirtualTrees;
- Type
- PMyRec = ^TMyRec;
- TMyRec = Record
- ConName, ConSkypeID, CtgName : String;
- CtgID : Integer;
- End;
- type
- TfrmMain = class(TForm)
- VT: TVirtualStringTree;
- procedure VTGetNodeDataSize(Sender: TBaseVirtualTree;
- var NodeDataSize: Integer);
- procedure VTFreeNode(Sender: TBaseVirtualTree; Node: PVirtualNode);
- procedure VTGetText(Sender: TBaseVirtualTree; Node: PVirtualNode;
- Column: TColumnIndex; TextType: TVSTTextType; var CellText: string);
- procedure FormCreate(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- frmMain: TfrmMain;
- implementation
- {$R *.dfm}
- procedure TfrmMain.FormCreate(Sender: TObject);
- Var
- I, J : Integer;
- ParentNode : PVirtualNode;
- ParentData, ChildData : PMyRec;
- begin
- VT.NodeDataSize := SizeOf(TMyRec);
- VT.BeginUpdate;
- for I := 1 to 1000 do
- begin
- ParentNode := VT.AddChild(nil);
- ParentData := VT.GetNodeData(ParentNode);
- ParentData.CtgName := 'Category #'+IntToStr(I);
- ParentData.CtgID := Random(10000);
- for J := 1 to 1000 do
- begin
- ChildData := VT.GetNodeData(VT.AddChild(ParentNode));
- ChildData.ConName := 'Some Contact';
- ChildData.ConSkypeID := 'SomeSkypeID';
- end;
- end;
- VT.EndUpdate;
- end;
- procedure TfrmMain.VTFreeNode(Sender: TBaseVirtualTree; Node: PVirtualNode);
- Var
- Data : PMyRec;
- begin
- Data := VT.GetNodeData(Node);
- if Assigned(Data) then
- begin
- Data.ConName := '';
- Data.ConSkypeID := '';
- Data.CtgName := '';
- Finalize(Data^);
- end;
- end;
- procedure TfrmMain.VTGetNodeDataSize(Sender: TBaseVirtualTree;
- var NodeDataSize: Integer);
- begin
- NodeDataSize := SizeOf(TMyRec);
- end;
- procedure TfrmMain.VTGetText(Sender: TBaseVirtualTree; Node: PVirtualNode;
- Column: TColumnIndex; TextType: TVSTTextType; var CellText: string);
- Var
- Data : PMyRec;
- begin
- Data := VT.GetNodeData(Node);
- case VT.GetNodeLevel(Node) of
- 0:
- begin
- case Column of
- 0: CellText := Data.CtgName;
- 1: CellText := IntToStr(Data.CtgID);
- end;
- end;
- 1:
- begin
- case Column of
- 0: CellText := Data.ConName;
- 1: CellText := Data.ConSkypeID;
- end;
- end;
- end;
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement