お知らせ

電子会議

ライブラリ

パレット

Delphi FAQ検索

Delphi FAQ一覧

サンプル蔵





FDelphi FAQ
16番会議室「玉石混淆みんなで作るSample蔵」に寄せられたサンプル

"TDirectoryOutLineで指定Dirを開く"




//深い階層のディレクトリを上から一枚ずつ返す
procedure getNextDir(var tugi,nokori:string);
var
   yenLoc:integer;
begin
   if Length(nokori)=0 then
   begin
      tugi:='';
      nokori:='';
   end
   else
   begin
      yenLoc:=ansiPos('\',nokori);
      if yenLoc=0 then
      begin
         tugi:=nokori;
         nokori:='';
      end
      else
      begin
         tugi:=copy(nokori,1,yenLoc-1);
         nokori:=copy(nokori,YenLoc+1,256);
      end;
   end;
end;

//指定されたDirectoryOutLineの指定されたディレクトリを開く
procedure OpenDirOf(theBox:TDirectoryOutline;dir:string);
var
   tugi:String;
   i,lastIndex:integer;
begin
   //ドライブは先に設定してあることが前提
   LastIndex:=1;
   theBox.Items[LastIndex].expand;
   getNextDir(tugi,Dir);//tugi:c:\
   while Dir<>'' do
   begin
      getNextDir(tugi,Dir);//一回目はtugi:Delphi
      for i:=LastIndex+1 to theBox.ItemCount-1 do
      begin
         if theBox.items[i].Text=tugi then
         begin
            lastIndex:=i;
            theBox.Items[LastIndex].expand;
            break;
         end;
      end;
   end;
   theBox.Row:=LastIndex-1;
end;

//使い方例えばTForm1.FormCreateで      
DirectoryOutline1.Drive:='c';
OpenDirOf(DirectoryOutline1,'c:\delphi\bin');

☆☆☆ わからないときサンプル蔵 わかったときサンプル蔵 ☆☆☆
                                 97/12/13(土) 21:28 凛(MXB01744)

Original document by 凛              氏 ID:(MXB01744)


ここにあるドキュメントは NIFTY SERVEの Delphi Users' Forum の16番会議室「玉石混淆みんなで作るSample蔵」に投稿されたサンプルです。これらのサンプルはボーランド株式会社がサポートする公式のものではありません。また、必ずしも動作が検証されているものではありません。これらのサンプルを使用したことに起因するいかなる損害も投稿者、およびフォーラムスタッフはその責めを負いません。使用者のリスクの範疇でご使用下さい。

Copyright 1996-2002 Delphi Users' Forum