// Ein Pfad
(einschl.
Laufwerksangabe!)
wird in einem uses FileCtrl;
function ExpDir(dol: TDirectoryOutline; dir: string): boolean;
var idx, p, i: integer;
s: string;
begin
result := false;
dir := trim(dir);
if length(dir) = 1 then dir := dir + ':';
if ansilastchar(dir) <> '\' then dir := dir + '\';
if (dir[2] = ':') and directoryexists(dir) then begin
try
idx := 1;
dol.drive := dir[idx];
dol.items[idx].collapse;
dir := copy(dir, 4, max_path);
dol.items[idx].expand;
while dir <> '' do begin
p := pos('\', dir);
s := copy(dir, 1, p - 1);
dir := copy(dir, p + 1, max_path);
for i := idx to dol.itemcount do
if dol.items[i].text = s then begin
idx := i;
dol.items[i].expand;
break;
end;
end;
dol.row := idx - 1;
except
exit;
end;
result := true;
end;
end;
// Beispielaufruf
procedure TForm1.Button4Click(Sender: TObject);
begin
if not ExpDir(DirectoryOutline1, 'c:\programme\icq\2000b')
then showmessage('Fehler');
end;
|





