Ok. Dank' Dir. Hab jetzt (erst mal) was nach VSTKeyPress geschrieben. Ich verwende statt Node.Data sowieso eine kleine Helperklasse zur Verwaltung der Captions und Items, damit geht es dann auch.
Delphi-Quellcode:
procedure TDirectoryTreeView.VSTKeyPress(Sender: TObject; var Key: Char);
var
Node: PVirtualNode;
begin
Node := FVirtualDirectoryTree.GetNext(Key);
if Node <> nil then
begin
Key := #0;
VSTChange(FVST, Node);
end;
end;
..
function TVirtualDirectoryTree.GetVisible(Node: PVirtualNode): boolean;
var
Temp: PVirtualNode;
begin
Result := true;
Temp := Node.Parent;
while (Temp <> nil) and (Temp <> FVST.GetFirst) do
begin
if not FVST.Expanded[Temp] then
begin
Result := false;
Exit;
end;
Temp := Temp.Parent;
end;
end;
function TVirtualDirectoryTree.GetNext(const C: Char): PVirtualNode;
const
CharSet: string = '0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZÄÖÜ_abcdefghijklmnopqrstuvwxyzäöüß';
var
Node: PVirtualNode;
A, B: Char;
S: string;
begin
Result := nil;
FWorking := true;
try
if Pos(C, CharSet) > 0 then
begin
A := FUpperCaseChar[C];
Node := FindNodePath(FDirectory);
Node := FVST.GetNext(Node);
while Node <> nil do
begin
S := Caption[Node];
B := FUpperCaseChar[S[1]];
if (A = B) and Visible[Node] then
begin
Result := Node;
Exit;
end;
Node := FVST.GetNext(Node);
end;
end;
finally
FWorking := false;
end;
end;