Registriert seit: 24. Mär 2004
Ort: bei Hannover
2.416 Beiträge
Delphi XE5 Professional
|
Re: Suche im VST - Suche nächster - Suche vorheriger
25. Feb 2008, 11:16
wenn ich es nicht ganz falsch verstanden habe:
Delphi-Quellcode:
ta = class
fs: string;
constructor Create(s:string);
end;
// musterdaten
procedure TForm1.Button1Click(Sender: TObject);
var
nodea,nodeb: PVirtualNode;
begin
VirtualStringTree1.NodeDataSize:=sizeof(ta);
nodea:=VirtualStringTree1.AddChild(nil, ta.Create('a'));
nodeb:=VirtualStringTree1.AddChild(nodea, ta.Create('aa'));
VirtualStringTree1.AddChild(nodeb, ta.Create('aaa'));
nodeb:=VirtualStringTree1.AddChild(nodea, ta.Create('ab'));
VirtualStringTree1.AddChild(nodeb, ta.Create('aba'));
VirtualStringTree1.AddChild(nodeb, ta.Create('abb'));
nodea:=VirtualStringTree1.AddChild(nil, ta.Create('b'));
nodeb:=VirtualStringTree1.AddChild(nodea, ta.Create('ba'));
VirtualStringTree1.AddChild(nodeb, ta.Create('baa'));
nodeb:=VirtualStringTree1.AddChild(nodea, ta.Create('bb'));
VirtualStringTree1.AddChild(nodeb, ta.Create('bba'));
VirtualStringTree1.AddChild(nodeb, ta.Create('bbb'));
VirtualStringTree1.FullExpand();
end;
// vorwärtssuche
procedure TForm1.Button2Click(Sender: TObject);
var
node: PVirtualNode;
a: ta;
begin
VirtualStringTree1.ClearSelection;
if VirtualStringTree1.FocusedNode=nil then
node:=VirtualStringTree1.GetFirst
else
node:=VirtualStringTree1.FocusedNode;
while node<>nil do
begin
node:=VirtualStringTree1.GetNext(node);
if node=nil then
begin
MessageDlg('ende', mtWarning, [mbOK], 0);
break;
end;
a:=ta(VirtualStringTree1.GetNodeData(node)^);
if pos(Edit1.text, a.fs)>0 then
begin
VirtualStringTree1.FocusedNode:=node;
VirtualStringTree1.Selected[node]:=true;
break;
end;
end;
end;
// rückwärtssuche
procedure TForm1.Button3Click(Sender: TObject);
var
node: PVirtualNode;
a: ta;
begin
VirtualStringTree1.ClearSelection;
if VirtualStringTree1.FocusedNode=nil then
node:=VirtualStringTree1.GetFirst
else
node:=VirtualStringTree1.FocusedNode;
while node<>nil do
begin
node:=VirtualStringTree1.GetPrevious(node);
if node=nil then
begin
MessageDlg('ende', mtWarning, [mbOK], 0);
break;
end;
a:=ta(VirtualStringTree1.GetNodeData(node)^);
if pos(Edit1.text, a.fs)>0 then
begin
VirtualStringTree1.FocusedNode:=node;
VirtualStringTree1.Selected[node]:=true;
break;
end;
end;
end;
procedure TForm1.VirtualStringTree1GetText(Sender: TBaseVirtualTree;
Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType;
var CellText: WideString);
var
a: ta;
begin
a:=ta(sender.GetNodeData(node)^);
CellText:=a.fs;
end;
{ ta }
constructor ta.Create(s: string);
begin
inherited Create;
fs:=s;
end;
|
|
Zitat
|