home *** CD-ROM | disk | FTP | other *** search
/ Delphi 2 - Developers' Solutions / Delphi 2 Developers' Solutions.iso / dds / chap03 / howto04 / drwsutl3.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-03-06  |  100.5 KB  |  2,653 lines

  1. unit Drwsutl3;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  7.   Forms, Dialogs, StdCtrls, Buttons, ExtCtrls, ShellAPI, FileCtrl, DRWSUtl1;
  8.  
  9. const
  10.   EOC_CHANGEDIR = 1;  { Error Operation Code for change directory failure }
  11.   EOC_SOURCECOPY = 2; { Error Operation Code for source copy failure      }
  12.   EOC_DESTCOPY = 3;   { Error Operation Code for destination copy failure }
  13.   EOC_DELETEFILE = 4; { Error Operation Code for file delete failure      }
  14.   EOC_DELETEDIR = 5;  { Error Operation Code for directory delete failure }
  15.   EOC_RENAMEFILE = 6; { Error Operation Code for renaming failure         }
  16.   EOC_MAKEDIR = 7;    { Error Operation Code for MkDir failure            }
  17.   EOC_SETATTR = 8;    { Error Operation Code for Set Attributes failure   }
  18.  
  19.   FAC_COPY = 1;       { File Action Code for recursive copying            }
  20.   FAC_MOVE = 2;       { File Action Code for recursive moving             }
  21.   FAC_DELETE = 3;     { File Action Code for recursive deletion           }
  22. type
  23.   { This is a descendant of TFileListbox }
  24.   { Which puts icons of files into the   }
  25.   { Objects array rather than the stand- }
  26.   { ard bitmaps.                         }
  27.   TIconFileListBox = class( TFileListBox )
  28.   public
  29.     { public methods and data }
  30.     procedure ReadFileNames; override;
  31.     function GetNextSelection( SourceDirectory : String;
  32.               var CurrentItem : Integer ) : String;
  33.     constructor Create(AOwner : TComponent); override; { override create    }
  34.     procedure TheDblClick( Sender : TObject );{ This holds override dblclick }
  35.   end;
  36.   TFileWorkBench = class( TComponent )
  37.   public
  38.     GlobalError        : Integer;  { This is used by FMXUCopyFile for er code }
  39.     GlobalErrorType    : Integer;  { This holds the Operation code            }
  40.     function ForceTrailingBackSlash( const TheFileName : String ) : String;
  41.     function StripNonRootTrailingBackSlash(
  42.               const TheFileName : String ) : String;
  43.     procedure GetFileAttributes( TheFile : String; var IsDirectory , IsArchive ,
  44.                 IsVolumeID , IsHidden , IsReadOnly , IsSysFile : Boolean );
  45.     procedure HandleIOException( TheOpCode : Integer; ThePath : String;
  46.                                  TheMessage : String; TheCode : Integer );
  47.     procedure HandleDOSError( TheOpCode : Integer; ThePath : String;
  48.                 TheCode : Integer );
  49.     function CopyFile( TargetPath ,
  50.                DestinationPath : String ) : Boolean;
  51.     procedure ChangeTheDirectory( NewPath : String );
  52.     procedure ChangeTheDriveAndDirectory( NewDrive : Integer );
  53.     procedure CopyTheFile( OldPath , NewPath : String );
  54.     procedure MoveTheFile( OldPath , NewPath : String );
  55.     procedure DeleteTheFile( ThePath : String );
  56.     procedure RenameTheFile( OldPath , NewName : String );
  57.     procedure CreateNewDirectory( NewPath : String );
  58.     procedure RemoveDirectory( ThePath : String );
  59.     procedure SetFileAttributes( TheFile  : String; TheAttributes : Integer );
  60.     procedure RecursivelyCopyDirectory( OldPath , NewPath : String );
  61.     procedure RecursivelyMoveDirectory( OldPath , NewPath : String );
  62.     procedure RecursivelyDeleteDirectory( ThePath : String );
  63.     procedure HandleRecursiveAction( StartingPath , NewPath : String;
  64.                ActionCode : Integer );
  65.   end;
  66.   TFileIconPanel = class( TPanel )
  67.   private
  68.     { Private declarations }
  69.     FHighlightColor : TColor;                 { This holds bright edge bevel }
  70.     FShadowColor    : TColor;                 { This holds dark edge bevel   }
  71.     procedure TheMouseDown(Sender: TObject;
  72.       Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  73.     procedure TheMouseUp(Sender: TObject;
  74.       Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  75.     procedure WMLButtonDblClk(var Message: TWMLButtonDblClk);
  76.      message WM_LBUTTONDBLCLK;
  77.     procedure TheDragOver(Sender, Source: TObject; X,
  78.       Y: Integer; State: TDragState; var Accept: Boolean);
  79.     procedure TheDragDrop(Sender, Source: TObject; X,
  80.       Y: Integer);
  81.   protected                                   { event method procedure.      }
  82.     { Protected declarations }
  83.     procedure Paint; override;                { This allows custom painting  }
  84.   public
  85.     { Public declarations }
  86.     FTheIcon : TIcon;                         { This is the display icon    }
  87.     FTheName : String;                        { This is the filename        }
  88.     FTheLabel : TLabel;                       { This is the display label   }
  89.     Selected : Boolean;                       { This holds selection status }
  90.     constructor Create(AOwner : TComponent); override; { override create    }
  91.     procedure Initialize( PanelX              ,             { Left          }
  92.                           PanelY              ,             { Top           }
  93.                           PanelWidth          ,             { Width         }
  94.                           PanelHeight         ,             { Height        }
  95.                           PanelBevelWidth     ,             { Bevel Width   }
  96.                           LabelFontSize         : Integer;  { Font size     }
  97.                           PanelColor          ,             { Main color    }
  98.                           PanelHighlightColor ,             { Bright color  }
  99.                           PanelShadowColor    ,             { Dark color    }
  100.                           LabelTextColor        : TColor;   { Text color    }
  101.                           TheFilename         ,             { Filename      }
  102.                           LabelFontName         : String;   { Font name     }
  103.                           LabelFontStyle        : TFontStyles;  { Font style}
  104.                           ExtraData             : Integer       );  { Drive }
  105.     destructor Destroy; override;             { override destroy to free    }
  106.   end;
  107.   TFileIconPanelScrollBox = class( TScrollBox )
  108.   public
  109.     { Public methods and data }
  110.     TheFWB              : TFileWorkBench; { Used for file manipulation         }
  111.     IconsNeedRefreshing : Boolean;                   { Flag to redo display    }
  112.     TheIconSize        : Integer;   { Holds Individual Icon size               }
  113.     TheIconSpacing     : Integer;   { Holds total icon footprint               }
  114.     MaxIconsInARow     : Integer;   { Set for screen size.                     }
  115.     TheStoredHandle    : HWnd;
  116.     TheParentForm      : TForm;
  117.     procedure Update;                                { Called to reset display }
  118.     constructor Create( AOwner : TComponent ); override;  { Override inherited }
  119.     procedure ClearTheFIPs;                          { Clears the FIPs safely  }
  120.     procedure AddDriveIcons( var XCounter , YCounter : Integer ); { Add drives }
  121.     procedure GetColorsForFileIcon( TheFile : String;
  122.                var BC , HC , SC , TC : TColor );
  123.     procedure GetIconsForEntireDirectory( TargetPath  : String );
  124.     function GetNextSelection( SourceDirectory : String;
  125.               var CurrentItem : Integer ) : String;
  126.     procedure DisplayRecursiveSearchResults(
  127.       TheStartingDirectory : String );
  128.   end;
  129.   TIOManager = class( TComponent )
  130.   public
  131.     Parent : TForm;
  132.     WhichButton : TMouseButton;
  133.     WhichState  : TShiftState;
  134.     function WasLeftPressed : Boolean;
  135.     function WasRightPressed : Boolean;
  136.     function WasMiddlePressed : Boolean;
  137.     function WasALTPressed : Boolean;
  138.     function WasSHIFTPressed : Boolean;
  139.     function WasCTRLPressed : Boolean;
  140.     procedure OnF1Pressed(Sender: TObject; var Key: Word;
  141.      Shift: TShiftState);
  142.     procedure OnF2Pressed(Sender: TObject; var Key: Word;
  143.      Shift: TShiftState);
  144.     procedure OnF3Pressed(Sender: TObject; var Key: Word;
  145.      Shift: TShiftState);
  146.     procedure OnF4Pressed(Sender: TObject; var Key: Word;
  147.      Shift: TShiftState);
  148.     procedure OnF5Pressed(Sender: TObject; var Key: Word;
  149.      Shift: TShiftState);
  150.     procedure OnF6Pressed(Sender: TObject; var Key: Word;
  151.      Shift: TShiftState);
  152.     procedure OnF7Pressed(Sender: TObject; var Key: Word;
  153.      Shift: TShiftState);
  154.     procedure OnF8Pressed(Sender: TObject; var Key: Word;
  155.      Shift: TShiftState);
  156.     procedure OnF9Pressed(Sender: TObject; var Key: Word;
  157.      Shift: TShiftState);
  158.     procedure OnF10Pressed(Sender: TObject; var Key: Word;
  159.      Shift: TShiftState);
  160.     procedure OnF11Pressed(Sender: TObject; var Key: Word;
  161.      Shift: TShiftState);
  162.     procedure OnF12Pressed(Sender: TObject; var Key: Word;
  163.      Shift: TShiftState);
  164.  end;
  165.   { This procedure gets an icon for a file using FindExecutable  }
  166.   { and ExtractIcon. (assumes file/dir is passed)                }
  167.   procedure GetIconForFile( TheName : String; var TheIcon : TIcon );
  168.   { This procedure spaces out the bitbtn components on a tpanel }
  169.   procedure SpacePanelButtons( WhichPanel : TPanel );
  170.     procedure FMXUCopyFile(const FileName, DestName: String; var GlobalErrorType ,
  171.                GlobalErrorCode : Integer );
  172.  
  173. var TheIOManager : TIOManager;
  174.     GlobalAbortFlag : Boolean;
  175.  
  176. implementation
  177. {$R DRWSUTL3.RES}                 { Import custom resource file }
  178. uses UFMGR13;
  179.  
  180. { It has been edited to return viable error codes!             }
  181. procedure FMXUCopyFile(const FileName, DestName: String; var GlobalErrorType ,
  182.             GlobalErrorCode : Integer );
  183. var
  184.   CopyBuffer: Pointer; { buffer for copying }
  185.   BytesCopied: Longint;
  186.   TheAttr : Integer;
  187.   Source, Dest: Integer; { handles }
  188. const
  189.   ChunkSize: Longint = 8192; { copy in 8K chunks }
  190. begin
  191.   GetMem(CopyBuffer, ChunkSize); { allocate the buffer }
  192.   Source := FileOpen(FileName, fmShareDenyWrite); { open source file }
  193.   if Source < 0 then
  194.   begin  { error creating source file }
  195.     GlobalErrorType := EOC_SOURCECOPY;
  196.     GlobalErrorCode := -IOResult;
  197.     if GlobalErrorCode = 0 then GlobalErrorCode := -157;
  198.     FreeMem( CopyBuffer, ChunkSize );
  199.     exit;
  200.   end;
  201.   Dest := FileCreate(DestName); { create output file; overwrite existing }
  202.   if Dest < 0 then
  203.   begin  { error creating destination file }
  204.     FileClose( Source );
  205.     GlobalErrorType := EOC_DESTCOPY;
  206.     GlobalErrorCode := -IOResult;
  207.     if GlobalErrorCode = 0 then GlobalErrorCode := -159;
  208.     FreeMem( CopyBuffer , ChunkSize );
  209.     exit;
  210.   end;
  211.   {$I-}
  212.   repeat
  213.     BytesCopied := FileRead(Source, CopyBuffer^, ChunkSize); { read chunk}
  214.     if BytesCopied > 0 then { if we read anything... }
  215.     FileWrite(Dest, CopyBuffer^, BytesCopied); { ...write chunk }
  216.   until BytesCopied < ChunkSize; { until we run out of chunks }
  217.   {$I+}
  218.   GlobalErrorCode := -IOResult;  { get any error code which happens during copying }
  219.   FileClose(Dest); { close the destination file }
  220.   FileClose(Source); { close the source file }
  221.   FreeMem(CopyBuffer, ChunkSize); { free the buffer }
  222. end;
  223.  
  224. { This procedure spaces out the bitbtn components on a tpanel }
  225. procedure SpacePanelButtons( WhichPanel : TPanel );
  226. var TheCalculatedSpacing     ,            { Holds primary spacing }
  227.     TheFullCalculatedSpacing   : Integer; { Holds full spacing    }
  228.     Counter_1                  : Integer; { Loop counter          }
  229.     TotalIBs                   : Integer; { Gets total buttons    }
  230. begin
  231.   { Set up spacing values }
  232.   TotalIBs := WhichPanel.ControlCount;
  233.   TheCalculatedSpacing := (( WhichPanel.Width - 6 - ( TotalIbs * 49 ))
  234.    div ( TotalIbs + 1 ));
  235.   TheFullCalculatedSpacing := TheCalculatedSpacing + 49;
  236.   { Loop through all imported buttons and set their Left values }
  237.   for Counter_1 := 1 to WhichPanel.ControlCount do
  238.   begin
  239.     if Counter_1 = 1 then
  240.     begin
  241.       TBitBtn( WhichPanel.Controls[ Counter_1 - 1 ] ).Left := 3 +
  242.        TheCalculatedSpacing;
  243.     end
  244.     else
  245.     begin
  246.       TBitBtn( WhichPanel.Controls[ Counter_1 - 1 ] ).Left := 3 +
  247.        (( Counter_1 - 1 ) * TheFullCalculatedSpacing ) + TheCalculatedSpacing;
  248.     end;
  249.   end;
  250. end;
  251.  
  252. { This procedure gets an icon for a file using FindExecutable  }
  253. { and ExtractIcon. (assumes file/dir is passed)                }
  254. procedure GetIconForFile( TheName : String; var TheIcon : TIcon );
  255. var TheExt           : String; { File extension holder }
  256.     TheOtherPChar  ,           { Windows ASCIIZ string }
  257.     ThePChar         : PChar;  { Windows ASCIIZ string }
  258.     Dummy : Word;
  259. begin
  260.   { Check for directory and if so get directory icon from RES file }
  261.   if (( FileGetAttr( TheName ) and faDirectory ) = faDirectory ) then
  262.   begin
  263.     { Set up the PChar to communicate with Windows }
  264.     GetMem( TheOtherPChar , 255 );
  265.     { Convert Pascal-style string to ASCIIZ Pchar }
  266.     StrPCopy( TheOtherPChar , 'DIRECTORY' );
  267.     { Use API call to return icon handle of Icon Resource in FILECTRL.RES }
  268.     TheIcon.Handle := LoadIcon( hInstance , TheOtherPChar );
  269.     { Release memory from PChar }
  270.     FreeMem( TheOtherPChar , 255 );
  271.     { Leave }
  272.     exit;
  273.   end;
  274.   { Assume archive file; get its extension }
  275.   TheExt := Uppercase( ExtractFileExt( TheName ));
  276.   { If not an executable/image file then use FindExecutable to get icon }
  277.   if (( TheExt <> '.EXE' ) and ( TheExt <> '.BAT' ) and
  278.       ( TheExt <> '.PIF' ) and ( TheExt <> '.COM' )) then
  279.   begin
  280.     { Grab three chunks of memory }
  281.     GetMem( ThePChar , 255 );
  282.     { Set up the name and its directory in Windows string formats }
  283.     StrPCopy( ThePChar, TheName );
  284.     Dummy := 65535;
  285.     {**** Windows 95 Specialized call ****** }
  286.     TheIcon.Handle := ExtractAssociatedIcon( hInstance , ThePChar , Dummy );
  287.     if TheIcon.Handle = 0 then
  288.     begin
  289.       GetMem( TheOtherPChar , 255 );
  290.       StrPCopy( TheOtherPChar , 'NOICON' );
  291.       TheIcon.Handle := LoadIcon( hInstance , TheOtherPChar );
  292.       FreeMem( TheOtherPChar , 255 );
  293.       exit;
  294.     end;
  295.     FreeMem( ThePChar , 255 );
  296.   end
  297.   else
  298.   { Assume Windows Executable file, so get icon from it with ExtractIcon API }
  299.   begin
  300.     GetMem( ThePChar , 255 );
  301.     StrPCopy( ThePChar , TheName );
  302.     { Try to get first icon for file }
  303.     Dummy := 65535;
  304.     TheIcon.Handle := ExtractAssociatedIcon( hInstance , ThePChar , Dummy );
  305.     FreeMem( ThePChar , 255 );
  306.     { If handle is 0 invalid icon format so use default from RES file }
  307.     if TheIcon.Handle = 0 then
  308.     begin
  309.       GetMem( TheOtherPChar , 255 );
  310.       StrPCopy( TheOtherPChar , 'NOICON' );
  311.       TheIcon.Handle := LoadIcon( hInstance , TheOtherPChar );
  312.       FreeMem( TheOtherPChar , 255 );
  313.       exit;
  314.     end;
  315.   end;
  316. end;
  317.  
  318. { This procedure handles pressing of F1 for CCFileManagerForm }
  319. procedure TIoManager.OnF1Pressed(Sender: TObject; var Key: Word;
  320.   Shift: TShiftState);
  321. begin
  322.   MessageDlg( 'Help not implemented!' , mtInformation,[mbok],0);
  323. end;
  324.  
  325. { This procedure handles pressing of F2 for CCFileManagerForm }
  326. procedure TIoManager.OnF2Pressed(Sender: TObject; var Key: Word;
  327.   Shift: TShiftState);
  328. begin
  329.   TCCFileMgrForm( Parent ).BitBtn1Click( Sender );
  330. end;
  331.  
  332. { This procedure handles pressing of F3 for CCFileManagerForm }
  333. procedure TIoManager.OnF3Pressed(Sender: TObject; var Key: Word;
  334.   Shift: TShiftState);
  335. begin
  336.   TCCFileMgrForm( Parent ).BitBtn2Click( Sender );
  337. end;
  338.  
  339. { This procedure handles pressing of F4 for CCFileManagerForm }
  340. procedure TIoManager.OnF4Pressed(Sender: TObject; var Key: Word;
  341.   Shift: TShiftState);
  342. begin
  343.   TCCFileMgrForm( Parent ).BitBtn3Click( Sender );
  344. end;
  345.  
  346. { This procedure handles pressing of F5 for CCFileManagerForm }
  347. procedure TIoManager.OnF5Pressed(Sender: TObject; var Key: Word;
  348.   Shift: TShiftState);
  349. begin
  350.   TCCFileMgrForm( Parent ).BitBtn4Click( Sender );
  351. end;
  352.  
  353. { This procedure handles pressing of F6 for CCFileManagerForm }
  354. procedure TIoManager.OnF6Pressed(Sender: TObject; var Key: Word;
  355.   Shift: TShiftState);
  356. begin
  357.   TCCFileMgrForm( Parent ).BitBtn5Click( Sender );
  358. end;
  359.  
  360. { This procedure handles pressing of F7 for CCFileManagerForm }
  361. procedure TIoManager.OnF7Pressed(Sender: TObject; var Key: Word;
  362.   Shift: TShiftState);
  363. begin
  364.   TCCFileMgrForm( Parent ).BitBtn9Click( Sender );
  365. end;
  366.  
  367. { This procedure handles pressing of F8 for CCFileManagerForm }
  368. procedure TIoManager.OnF8Pressed(Sender: TObject; var Key: Word;
  369.   Shift: TShiftState);
  370. begin
  371.   TCCFileMgrForm( Parent ).BitBtn6Click( Sender );
  372. end;
  373.  
  374. { This procedure handles pressing of F9 for CCFileManagerForm }
  375. procedure TIoManager.OnF9Pressed(Sender: TObject; var Key: Word;
  376.   Shift: TShiftState);
  377. begin
  378.   TCCFileMgrForm( Parent ).Update;
  379. end;
  380.  
  381. { This procedure handles pressing of F10 for CCFileManagerForm }
  382. procedure TIoManager.OnF10Pressed(Sender: TObject; var Key: Word;
  383.   Shift: TShiftState);
  384. begin
  385.   TCCFileMgrForm( Parent ).BitBtn7Click( Sender );
  386. end;
  387.  
  388. { This procedure handles pressing of F11 for CCFileManagerForm }
  389. procedure TIoManager.OnF11Pressed(Sender: TObject; var Key: Word;
  390.   Shift: TShiftState);
  391. begin
  392.   TCCFileMgrForm( Parent ).BitBtn8Click( Sender );
  393. end;
  394.  
  395. { This procedure handles pressing of F12 for CCFileManagerForm }
  396. procedure TIoManager.OnF12Pressed(Sender: TObject; var Key: Word;
  397.   Shift: TShiftState);
  398. begin
  399.   TCCFileMgrForm( Parent ).BitBtn10Click( Sender );
  400. end;
  401.  
  402. { Returns True if the Left Button was pressed in the last mouse operation }
  403. function TIOManager.WasLeftPressed : Boolean;
  404. begin
  405.   if ( mbLeft = WhichButton ) then WasLeftPressed := true else
  406.    WasLeftPressed := false;
  407. end;
  408.  
  409. { Returns true if the Right Button was pressed in the last mouse operation }
  410. function TIOManager.WasRightPressed : Boolean;
  411. begin
  412.   if mbRight = WhichButton then WasRightPressed := true else
  413.    WasRightPressed := false;
  414. end;
  415.  
  416. { Returns true if the Middle Button was pressed in the last mouse operation }
  417. function TIOManager.WasMiddlePressed : Boolean;
  418. begin
  419.   if mbMiddle = WhichButton then WasMiddlePressed := true else
  420.    WasMiddlePressed := false;
  421. end;
  422.  
  423. { Returns true if the ALT key was down during the last IO operation }
  424. function TIOManager.WasALTPressed : Boolean;
  425. begin
  426.   if ssAlt in WhichState then WasALTPressed := true else
  427.    WasALTPressed := false;
  428. end;
  429.  
  430. { Returns true if either SHIFT key was down during the last IO operation }
  431. function TIOManager.WasSHIFTPressed : Boolean;
  432. begin
  433.   if ssShift in WhichState then WasSHIFTPressed := true else
  434.    WasSHIFTPressed := false;
  435. end;
  436.  
  437. { Returns true if the Control Key was down during the last IO operation }
  438. function TIOManager.WasCTRLPressed : Boolean;
  439. begin
  440.   if ssCtrl in WhichState then WasCTRLPressed := true else
  441.    WasCTRLPressed := false;
  442. end;
  443.  
  444.  
  445. { This procedure does a fully error-trapped change directory }
  446. procedure TFileWorkBench.ChangeTheDirectory( NewPath : String );
  447. var CurrentDirectory : String;
  448. begin
  449.   if NewPath = '..' then
  450.   begin { Back up one level }
  451.     {$I+}
  452.     try
  453.       { Find the current directory }
  454.       GetDir( 0 , CurrentDirectory );
  455.       { Use EFP to move up one level }
  456.       CurrentDirectory := ExtractFilePath( CurrentDirectory );
  457.       { Strip trailing \ if not root }
  458.       CurrentDirectory := StripNonRootTrailingBackSlash( CurrentDirectory );
  459.       { Try the change to the new drive }
  460.       ChDir( CurrentDirectory );
  461.     except
  462.       { if any exception occurs instantiate exception and show }
  463.       On E:EInOutError do
  464.       begin
  465.         { Call custom error display/lookup procedure }
  466.         HandleIOException( EOC_CHANGEDIR , CurrentDirectory ,
  467.          E.Message , E.ErrorCode );
  468.       end;
  469.     end;
  470.   end
  471.   else
  472.   begin { Change to explicit path }
  473.     {$I+}
  474.     try
  475.       { Get target directory path }
  476.       CurrentDirectory := NewPath;
  477.       { Strip trailing \ if not root }
  478.       CurrentDirectory := StripNonRootTrailingBackSlash( CurrentDirectory );
  479.       { Try the change to the new drive }
  480.       ChDir( CurrentDirectory );
  481.     except
  482.       { if any exception occurs instantiate exception and show }
  483.       On E:EInOutError do
  484.       begin
  485.         { Call custom error display/lookup procedure }
  486.         HandleIOException( EOC_CHANGEDIR , CurrentDirectory ,
  487.          E.Message , E.ErrorCode );
  488.       end;
  489.     end;
  490.   end;
  491. end;
  492.  
  493. { This procedure does a fully error-trapped change directory }
  494. procedure TFileWorkBench.ChangeTheDriveAndDirectory( NewDrive : Integer );
  495. var CurrentDirectory : String;
  496. begin
  497.   {$I+}
  498.   try
  499.     { Find the working directory on new drive }
  500.     GetDir( NewDrive , CurrentDirectory );
  501.     { Try the change to the new drive }
  502.     ChDir( CurrentDirectory );
  503.   except
  504.     { if any exception occurs instantiate exception and show }
  505.     On E:EInOutError do
  506.     begin
  507.       { Call custom error display/lookup procedure }
  508.       HandleIOException( EOC_CHANGEDIR , CurrentDirectory ,
  509.        E.Message , E.ErrorCode );
  510.     end;
  511.   end;
  512. end;
  513.  
  514. { This procedure copies a single file with error trapping }
  515. procedure TFileWorkBench.CopyTheFile( OldPath , NewPath : String );
  516. var AResult : Boolean; { Internal data flag }
  517. begin
  518.   { If Copyfile returns false an error occurred }
  519.   AResult := CopyFile( OldPath , NewPath +
  520.    ExtractFileName( OldPath ));
  521.   { Display meaningful error message }
  522.   if not AResult then HandleDOSError( GlobalErrorType , OldPath, GlobalError );
  523. end;
  524.  
  525. { This procedure moves a file by copying and delete it }
  526. procedure TFileWorkBench.MoveTheFile( OldPath , NewPath : String );
  527. var AResult : Boolean; { Internal data flag }
  528.     TheFile : File;    { Use to get errors  }
  529. begin
  530.   { If Copyfile returns false an error occurred }
  531.   AResult := CopyFile( OldPath , NewPath +
  532.     ExtractFileName( OldPath ));
  533.   { Display meaningful error message }
  534.   if not AResult then HandleDOSError( GlobalErrorType ,
  535.     OldPath , GlobalError );
  536.   { After valid copying, delete source file }
  537.   {$I+}
  538.   if AResult then try
  539.     { Use this trick to get valid exception handling }
  540.     AssignFile( TheFile , OldPath );
  541.     { Use erase because Deletefile doesn't give exceptions! }
  542.     Erase( TheFile );
  543.   except
  544.     { if any exception occurs instantiate exception and show }
  545.     On E:EInOutError do
  546.     begin
  547.       { Call custom error display/lookup procedure }
  548.       HandleIOException( EOC_DELETEFILE , OldPath ,
  549.        E.Message , E.ErrorCode );
  550.     end;
  551.   end;
  552. end;
  553.  
  554. { This procedure safely deletes a single file }
  555. procedure TFileWorkBench.DeleteTheFile( ThePath : String );
  556. var TheFile : File; { Internal file handle }
  557. begin
  558.   {$I+}
  559.   try
  560.     { Use this trick to get valid exception handling }
  561.     AssignFile( TheFile , ThePath );
  562.     { Use erase because Deletefile doesn't give exceptions! }
  563.     Erase( TheFile );
  564.   except
  565.     { if any exception occurs instantiate exception and show }
  566.     On E:EInOutError do
  567.     begin
  568.       { Call custom error display/lookup procedure }
  569.       HandleIOException( EOC_DELETEFILE , ThePath ,
  570.        E.Message , E.ErrorCode );
  571.     end;
  572.   end;
  573. end;
  574.  
  575. { This procedure renames a file with full error trapping }
  576. procedure TFileWorkBench.RenameTheFile( OldPath , NewName : String );
  577. var TheFile : File; { Internal file handle }
  578. begin
  579.   {$I+}
  580.   try
  581.     { Use this trick to get valid exception handling }
  582.     AssignFile( TheFile , OldPath );
  583.     { Use this because RenameFile doesn't give exceptions! }
  584.     Rename( TheFile , NewName );
  585.   except
  586.     { if any exception occurs instantiate exception and show }
  587.     On E:EInOutError do
  588.     begin
  589.       { Call custom error display/lookup procedure }
  590.       HandleIOException( EOC_RENAMEFILE , OldPath  ,
  591.        E.Message , E.ErrorCode );
  592.     end;
  593.   end;
  594. end;
  595.  
  596. { This procedure creates a new directory with full error trapping }
  597. procedure TFileWorkBench.CreateNewDirectory( NewPath : String );
  598. begin
  599.   {$I+}
  600.   try
  601.     Mkdir( NewPath );
  602.   except
  603.     { if any exception occurs instantiate exception and show }
  604.     On E:EInOutError do
  605.     begin
  606.       { Call custom error display/lookup procedure }
  607.       HandleIOException( EOC_MAKEDIR , NewPath  ,
  608.        E.Message , E.ErrorCode );
  609.     end;
  610.   end;
  611. end;
  612.  
  613. { This procedure remove a directory with full error trapping }
  614. procedure TFileWorkBench.RemoveDirectory( ThePath : String );
  615. begin
  616.   {$I+}
  617.   try
  618.     Rmdir( ThePath );
  619.   except
  620.     { if any exception occurs instantiate exception and show }
  621.     On E:EInOutError do
  622.     begin
  623.       { Call custom error display/lookup procedure }
  624.       HandleIOException( EOC_DELETEDIR , ThePath  ,
  625.        E.Message , E.ErrorCode );
  626.     end;
  627.   end;
  628. end;
  629.  
  630. { Use this to set the attributes of a file with error trapping }
  631. procedure TFileWorkBench.SetFileAttributes( TheFile  : String;
  632.            TheAttributes : Integer );
  633. var TheResult : Integer; { Holds error code if any }
  634. begin
  635.   { Attempt to set the attributes }
  636.   TheResult := FileSetAttr( TheFile , TheAttributes );
  637.   { if negative number error, so signal }
  638.   if TheResult < 0 then
  639.    HandleDOSError( EOC_SETATTR , TheFile , -TheResult );
  640. end;
  641.  
  642. { This procedure recursively copies a directory to a new path }
  643. procedure TFileWorkBench.RecursivelyCopyDirectory( OldPath , NewPath : String );
  644. var TheDir : String; { Holds source directory }
  645. begin
  646.   { Get the source directory to copy }
  647.   TheDir := ExtractFileName( OldPath );
  648.   { Force a backslash to the newpath variable }
  649.   NewPath := ForceTrailingBackSlash( NewPath );
  650.   { Add the source directory to the target path }
  651.   NewPath := NewPath + TheDir;
  652.   { Create a new directory with the new name }
  653.   CreateNewDirectory( NewPath );
  654.   { Force a backslash for compatibility }
  655.   NewPath := FOrcetrailingBackSlash( NewPath );
  656.   { Do the recursive call }
  657.   HandleRecursiveAction( OldPath , NewPath , FAC_COPY );
  658. end;
  659.  
  660. { This procedure recursively moves a directory tree }
  661. procedure TFileWorkBench.RecursivelyMoveDirectory( OldPath , NewPath : String );
  662. var TheDir    : String; { Holds source directory  }
  663.     SavedPath : String; { Holds saved dir to kill }
  664. begin
  665.   { Get the source directory to move }
  666.   TheDir := ExtractFileName( OldPath );
  667.   { Force a backslash to the newpath variable }
  668.   NewPath := ForceTrailingBackSlash( NewPath );
  669.   { Save the starting path just in case }
  670.   SavedPath := OldPath;
  671.   { Add the source directory to the target path }
  672.   NewPath := NewPath + TheDir;
  673.   { Create a new directory with the new name }
  674.   CreateNewDirectory( NewPath );
  675.   { Force a backslash for compatibility }
  676.   NewPath := FOrcetrailingBackSlash( NewPath );
  677.   { Do the recursive call }
  678.   HandleRecursiveAction( OldPath , NewPath , FAC_MOVE );
  679.   { Remove the source directory }
  680.   RemoveDirectory( SavedPath );
  681. end;
  682.  
  683. { This procedure handles recursively deleting an entire directory tree }
  684. procedure TFileWorkBench.RecursivelyDeleteDirectory( ThePath : String );
  685. begin
  686.   HandleRecursiveAction( ThePath , '' , FAC_DELETE );
  687. end;
  688.  
  689.  
  690. { This is the generic routine to copy, move, and delete whole directory trees }
  691. procedure TFileWorkBench.HandleRecursiveAction( StartingPath , NewPath : String;
  692.            ActionCode : Integer );
  693. { VITAL!!! These variables MUST be local for recursrion to work! }
  694. var
  695.     Finished        : Boolean;         { Loop flag              }
  696.     TheSR           : TSearchRec;      { Searchrecord for FF/FN }
  697.     TheResult       : Integer;         { return variable        }
  698.     TargetPath ,
  699.     FileMask   ,
  700.     TheWorkingDirectory ,
  701.     TheStoredWorkingDirectory ,
  702.     ModifiedDirectory  : String;       { path for FF/FN         }
  703.     TheFIP          : TFileIconPanel;  { generic FIP holder     }
  704.     ButtonColor   ,                    { main panel color       }
  705.     ButtonHLColor ,                    { bright panel color     }
  706.     ButtonSColor  ,                    { dark panel color       }
  707.     Textcolor       : TColor;          { label text color       }
  708.     TheFile         : File;
  709.  
  710. begin
  711.   { Set up the initial variables }
  712.   Finished := false;
  713.   TheWorkingDirectory := StartingPath;
  714.   TheStoredWorkingDirectory := TheWorkingDirectory;
  715.   TheWorkingDirectory := TheWorkingDirectory + '\*.*';
  716.   TargetPath := ExtractFilePath( TheWorkingDirectory );
  717.   { Make the call to FindFirst set to get any file }
  718.   TheResult := FindFirst( TheWorkingDirectory , faAnyFile , TheSR );
  719.   { loop through all files in the directory and delete them }
  720.   while not Finished do
  721.   begin
  722.     { Make call to FindNext, using only SearchRecord from FindFirst }
  723.     TheResult := FindNext( TheSR );
  724.     { A -1 result means no more files so exit }
  725.     if TheResult <> 0 then finished := true else
  726.     begin
  727.       if (( FileGetAttr( TargetPath + TheSR.Name ) and faDirectory )
  728.        <> faDirectory ) then
  729.       begin { A File }
  730.         case ActionCode of
  731.           FAC_COPY :
  732.               begin
  733.                 CopyTheFile( TargetPath + TheSR.Name , NewPath );
  734.               end;
  735.           FAC_MOVE :
  736.               begin
  737.                 MoveTheFile( TargetPath + TheSR.Name , NewPath );
  738.               end;
  739.           FAC_DELETE :
  740.               begin { Delete }
  741.                 if MessageDlg( 'Delete file ' + TargetPath + TheSR.Name + '?',
  742.                    mtConfirmation , mbYesNoCancel , 0 ) = mrYes then
  743.                     DeleteTheFile( TargetPath + TheSR.Name );
  744.               end;
  745.         end;
  746.       end;
  747.     end;
  748.   end;
  749.   { Set up the variables to do recursive calls on all directories}
  750.   Finished := false;
  751.   ModifiedDirectory := TheStoredWorkingdirectory + '\*.*';
  752.   { Make the call to FindFirst set to get any file, ignore result }
  753.   TheResult := FindFirst( ModifiedDirectory , faDirectory , TheSR );
  754.   while not Finished do
  755.   begin
  756.     { Make call to FindNext, using only SearchRecord from FindFirst }
  757.     TheResult := FindNext( TheSR );
  758.     { A -1 result means no more files so exit }
  759.     if TheResult <> 0 then
  760.       finished := true
  761.     else
  762.     begin
  763.       if TheSR.Name <> '..' then { Ignore backup in this case }
  764.       begin
  765.         if (( FileGetAttr( TargetPath + TheSR.Name ) and faDirectory )
  766.          = faDirectory ) then
  767.         begin
  768.           { Send in the new directory name }
  769.           ModifiedDirectory := TheStoredWorkingDirectory  + '\' +
  770.            TheSR.Name;
  771.           { Reproduce directory structure for recursion in copy/move }
  772.           NewPath := NewPath + TheSR.Name;
  773.           case ActionCode of
  774.             FAC_COPY , FAC_MOVE :
  775.                begin { Create ahead for move and copy }
  776.                  { Make the new directory for moving and copying }
  777.                  CreateNewDirectory( NewPath );
  778.                  { Force a backslash for compatibility }
  779.                  NewPath := ForceTrailingBackSlash( NewPath );
  780.                end;
  781.             FAC_DELETE :
  782.                begin  { No prior action needed for Delete }
  783.                end;
  784.           end;
  785.           { Do the recursive call }
  786.           HandleRecursiveAction( ModifiedDirectory , NewPath , ActionCode );
  787.           case ActionCode of
  788.             FAC_COPY :
  789.                begin { no action for copy }
  790.                end;
  791.             FAC_MOVE , FAC_DELETE :
  792.                begin  { Delete }
  793.                  { Get a confirmation }
  794.                  if MessageDlg( 'Remove Directory ' + TargetPath + TheSR.Name
  795.                   + '?', mtConfirmation , mbYesNoCancel , 0 ) = mrYes then
  796.                    RemoveDirectory( TargetPath + TheSR.Name );
  797.                end;
  798.           end;
  799.         end;
  800.       end;
  801.     end;
  802.   end;
  803. end;
  804.  
  805. { This is a generic copy routine taken from Delphi sample code }
  806. { This function calls the sample Copy code and handles errors }
  807. function TFileWorkBench.CopyFile( TargetPath ,
  808.           DestinationPath : String ) : Boolean;
  809. begin
  810.   { Set global error value to no error }
  811.   GlobalError := 0;
  812.   { Call the sample procedure to do the copy }
  813.   FMXUCopyFile( TargetPath, DestinationPath , GlobalErrorType , GlobalError );
  814.   { If no error return true else return false }
  815.   if GlobalError < 0 then CopyFile := false else
  816.    CopyFile := true;
  817. end;
  818.  
  819. { This procedure handles displaying a user-friendly Dialog box with a }
  820. { Message for Delphi IO exception errors.                             }
  821. procedure TFileWorkBench.HandleIOException( TheOpCode : Integer;
  822.            ThePath : String; TheMessage : String; TheCode : Integer );
  823. var ErrorMessageString : String;  { Holds internal data }
  824.     OperationString    : String;  { Holds internal data }
  825. begin
  826.   { clear to check for unrecognized code }
  827.   ErrorMessageString := '';
  828.   { Check against imported code }
  829.   case TheCode of
  830.     2    : ErrorMessageString := 'File not found';
  831.     3    : ErrorMessageString := 'Path not found';
  832.     4    : ErrorMessageString := 'Too many open files';
  833.     5    : ErrorMessageString := 'File access denied';
  834.     6    : ErrorMessageString := 'Invalid file handle';
  835.     12    : ErrorMessageString := 'Invalid file access code';
  836.     15    : ErrorMessageString := 'Invalid drive number';
  837.     16  : ErrorMessageString := 'Cannot remove current directory';
  838.     17    : ErrorMessageString := 'Cannot rename across drives';
  839.     100    : ErrorMessageString := 'Disk read error';
  840.     101    : ErrorMessageString := 'Disk write error';
  841.     102    : ErrorMessageString := 'File not assigned';
  842.     103    : ErrorMessageString := 'File not open';
  843.     104    : ErrorMessageString := 'File not open for input';
  844.     105    : ErrorMessageString := 'File not open for output';
  845.   end;
  846.   case TheOpCode of
  847.     EOC_CHANGEDIR : OperationString := 'Unable to Change Directory due to ';
  848.     EOC_SOURCECOPY : OperationString := 'Unable to Copy due to Source File ';
  849.     EOC_DESTCOPY : OperationString := 'Unable to Copy due to Destination File ';
  850.     EOC_DELETEFILE : OperationString := 'Unable to Delete File due to ';
  851.     EOC_DELETEDIR : OperationString := 'Unable to Delete Directory due to ';
  852.     EOC_RENAMEFILE : OperationString := 'Unable to Rename File due to ';
  853.     EOC_MAKEDIR : OperationString := 'Unable to Create New Directory due to ';
  854.     EOC_SETATTR : OperationString := 'Unable to Set File Attributes due to ';
  855.   end;
  856.   { If not recognized use message; not a DOS error; reset cursor for neatness }
  857.   if ErrorMessageString = '' then
  858.   begin
  859.     Screen.Cursor := crDefault;
  860.     MessageDlg( OperationString + ExtractFileName( ThePath ) + ' ' +
  861.      TheMessage , mtError , [mbOK],0);
  862.   end
  863.   else
  864.   begin
  865.     { Recognized DOS exception, reset cursor for neatness }
  866.     Screen.Cursor := crDefault;
  867.     MessageDlg( OperationString + ExtractFileName( ThePath ) + ' ' +
  868.      ErrorMessageString , mtError , [mbOK], 0 );
  869.   end;
  870. end;
  871.  
  872. { This procedure handles displaying a user-friendly Dialog box with a }
  873. { Message for DOS error codes.                                        }
  874. procedure TFileWorkBench.HandleDOSError( TheOpCode : Integer;
  875.            ThePath : String;  TheCode : Integer );
  876. var ErrorMessageString : String;  { internal message holder }
  877.     OperationString : String;     { internal message holder }
  878. begin
  879.   { clear the message holder to check for unrecognized code }
  880.   ErrorMessageString := '';
  881.   { Negate the code back to normal number and check to set string }
  882.   case -TheCode of
  883.     2    : ErrorMessageString := 'File not found';
  884.     3    : ErrorMessageString := 'Path not found';
  885.     4    : ErrorMessageString := 'Too many open files';
  886.     5    : ErrorMessageString := 'File access denied';
  887.     6    : ErrorMessageString := 'Invalid file handle';
  888.     12    : ErrorMessageString := 'Invalid file access code';
  889.     15    : ErrorMessageString := 'Invalid drive number';
  890.     16  : ErrorMessageString := 'Cannot remove current directory';
  891.     17    : ErrorMessageString := 'Cannot rename across drives';
  892.     100    : ErrorMessageString := 'Disk read error';
  893.     101    : ErrorMessageString := 'Disk write error';
  894.     102    : ErrorMessageString := 'File not assigned';
  895.     103    : ErrorMessageString := 'File not open';
  896.     104    : ErrorMessageString := 'File not open for input';
  897.     105    : ErrorMessageString := 'File not open for output';
  898.     157 : ErrormessageString := 'Could not open Source File';
  899.     159 : ErrormessageString := 'Could not open Target File';
  900.   end;
  901.   case TheOpCode of
  902.     EOC_CHANGEDIR : OperationString := 'Unable to Change Directory due to ';
  903.     EOC_SOURCECOPY : OperationString := 'Unable to Copy due to Source File ';
  904.     EOC_DESTCOPY : OperationString := 'Unable to Copy due to Destination File ';
  905.     EOC_DELETEFILE : OperationString := 'Unable to Delete File due to ';
  906.     EOC_DELETEDIR : OperationString := 'Unable to Delete Directory due to ';
  907.     EOC_RENAMEFILE : OperationString := 'Unable to Rename File due to ';
  908.     EOC_MAKEDIR : OperationString := 'Unable to Create New Directory due to ';
  909.     EOC_SETATTR : OperationString := 'Unable to Set File Attributes due to ';
  910.   end;
  911.   { If the string is empty an unrecognized code was sent in }
  912.   if ErrorMessageString = '' then
  913.   begin
  914.     { Sent up db based on source or target error; reset cursor for neatness }
  915.     Screen.Cursor := crDefault;
  916.     MessageDlg( OperationString + ExtractFileName( ThePath ) + ' Error Code: ' +
  917.      IntToStr( TheCode ) , mtError , [mbOK],0);
  918.   end
  919.   else  { Code is recognized, use message from case statement }
  920.   begin
  921.     { Format the output for source or target error }
  922.     Screen.Cursor := crDefault;
  923.     MessageDlg( OperationString + ExtractFileName( ThePath ) + ' ' +
  924.      ErrorMessageString , mtError , [mbOK], 0 );
  925.   end;
  926. end;
  927.  
  928. { This procedure sets the imported booleans to the file's attributes }
  929. procedure TFileWorkBench.GetFileAttributes( TheFile : String; var IsDirectory ,
  930.            IsArchive , IsVolumeID , IsHidden , IsReadOnly ,
  931.             IsSysFile : Boolean );
  932. var TheResult : Integer; { Traps for error code on VolumeID }
  933. begin
  934.   { Clear the imported flags for default }
  935.   IsDirectory := false;
  936.   IsArchive := false;
  937.   IsVolumeID := false;
  938.   IsHidden := False;
  939.   IsReadOnly := false;
  940.   IsSysFile := false;
  941.   { Make the Dos call }
  942.   TheResult := FileGetAttr( TheFile );
  943.   if TheResult < 0 then
  944.   begin
  945.     { Volume ID returns -2 (?) }
  946.     IsVolumeID := true;
  947.     { It has no other properties }
  948.     exit;
  949.   end;
  950.   { Use AND test to set all other properties }
  951.   if (( TheResult and faDirectory ) = faDirectory ) then IsDirectory := true;
  952.   if (( TheResult and faArchive ) = faArchive ) then IsArchive := true;
  953.   if (( TheResult and faVolumeID ) = faVolumeID ) then IsVolumeID := true;
  954.   if (( TheResult and faReadOnly ) = faReadOnly ) then IsReadOnly := true;
  955.   if (( TheResult and faHidden ) = faHidden ) then IsHidden := true;
  956.   if (( TheResult and faSysFile ) = faSysFile ) then IsSysFile := true;
  957. end;
  958.  
  959. { This function makes sure a pathname has a trailing \ }
  960. function TFileWorkBench.ForceTrailingBackSlash(
  961.           const TheFileName : String ) : String;
  962. var TempString : String;  { Used to hold function result }
  963. begin
  964.   { If no trailing \ add one (root will already have one.) }
  965.   if TheFileName[ Length( TheFileName ) ] <> '\' then
  966.    TempString := TheFileName + '\' else TempString := TheFileName;
  967.   { Return modified or non-modified string }
  968.   ForceTrailingBackslash := TempString;
  969. end;
  970.  
  971. { This function makes sure a non-root dir has no trailing \ }
  972. function TFileWorkBench.StripNonRootTrailingBackSlash(
  973.           const TheFileName : String ) : String;
  974. var TempString : String ; { Used to hold function result }
  975. begin
  976.   { Default is no change }
  977.   TempString := TheFileName;
  978.   { If not root then }
  979.   if Length( TheFileName ) > 3 then
  980.   begin
  981.     { If has a trailing backslash remove it }
  982.     if TheFileName[ Length( TheFileName )] = '\' then
  983.     begin
  984.       TempString := Copy( TheFileName , 1 ,
  985.        Length( TheFileName ) - 1 );
  986.     end;
  987.   end;
  988.   { Export the final result }
  989.   StripNonRootTrailingBackSlash := TempString;
  990. end;
  991.  
  992. { This gets the next selected listbox item }
  993. function TIconFileListBox.GetNextSelection( SourceDirectory : String;
  994.           var CurrentItem : Integer ): String;
  995. var TheResult : String;  { Internal storage }
  996.     finished  : boolean; { Loop flag        }
  997. begin
  998.   { If out of items to check signal and exit }
  999.   if CurrentItem > Items.Count then TheResult := '' else
  1000.   begin
  1001.     { Otherwise scan from current position till match or end }
  1002.     finished := false;
  1003.     while not finished do
  1004.     begin
  1005.       { Check against selected property }
  1006.       if Selected[ CurrentItem - 1 ] then
  1007.       begin
  1008.         { If selected then return it and abort loop }
  1009.         TheResult := SourceDirectory + Items[ CurrentItem - 1 ];
  1010.         finished := true;
  1011.         { Increment current position }
  1012.         CurrentItem := CurrentItem + 1;
  1013.      end
  1014.       else
  1015.       begin
  1016.         { Increment current position }
  1017.         CurrentItem := CurrentItem + 1;
  1018.         { Otherwise check for end of data and abort if out of entries }
  1019.         if CurrentItem > Items.Count then
  1020.         begin
  1021.           TheResult := '';
  1022.           finished := true;
  1023.         end;
  1024.       end;
  1025.     end;
  1026.   end;
  1027.   { Return stored result }
  1028.   GetNextSelection := TheResult;
  1029. end;
  1030.  
  1031. { Modified from VCL Source Copyright 1995 }
  1032. { Borland International, Inc.             }
  1033. { Use this to override display with icons }
  1034. procedure TIconFileListBox.ReadFileNames;
  1035. var
  1036.   AttrIndex   : TFileAttr;
  1037.   i           : Integer;
  1038.   FileExt     : string;
  1039.   MaskPtr     : PChar;
  1040.   Ptr         : PChar;
  1041.   AttrWord    : Word;
  1042.   TempPicture : TPicture;
  1043.   TempBmp     : TBitmap;
  1044.   TempIcon    : TIcon;
  1045. const
  1046.   Attributes: array[TFileAttr] of Word =
  1047.   ( DDL_READONLY , DDL_HIDDEN , DDL_SYSTEM , $0008 , DDL_DIRECTORY ,
  1048.     DDL_ARCHIVE  , DDL_EXCLUSIVE );
  1049. begin
  1050.   { if no handle allocated yet, this call will force         }
  1051.   { one to be allocated incorrectly (i.e. at the wrong time. }
  1052.   { In due time, one will be allocated appropriately.        }
  1053.   AttrWord := DDL_READWRITE;
  1054.   if HandleAllocated then
  1055.   begin
  1056.     { Set attribute flags based on values in FileType }
  1057.     for AttrIndex := ftReadOnly to ftArchive do
  1058.      if AttrIndex in FileType then
  1059.       AttrWord := AttrWord or Attributes[ AttrIndex ];
  1060.  
  1061.     { Use Exclusive bit to exclude normal files }
  1062.     if not ( ftNormal in FileType ) then
  1063.       AttrWord := AttrWord or DDL_EXCLUSIVE;
  1064.  
  1065.     ChDir( FDirectory ); { go to the directory we want }
  1066.     Clear;               { clear the list }
  1067.  
  1068.     GetMem( MaskPtr , 256 );
  1069.     StrPCopy( MaskPtr , FMask );
  1070.     while MaskPtr <> nil do
  1071.     begin
  1072.       Ptr := StrScan ( MaskPtr , ';' );
  1073.       if Ptr <> nil then  Ptr^ := #0;
  1074.       { build the list }
  1075.       SendMessage( Handle , LB_DIR , AttrWord , Longint( MaskPtr ));
  1076.       if Ptr <> nil then
  1077.       begin
  1078.         Ptr^ := ';';
  1079.         Inc ( Ptr );
  1080.       end;
  1081.       MaskPtr := Ptr;
  1082.     end;
  1083.     FreeMem( MaskPtr , 256 );
  1084.     { Now add the bitmaps }
  1085.     {---------------------------- begin custom code --------------------------}
  1086.     { Create the TPicture for exchange purposes }
  1087.     TempPicture := TPicture.Create;
  1088.     { Set it to icon widths }
  1089.     TempPicture.Bitmap.Width := 32;
  1090.     TempPicture.Bitmap.Height := 32;
  1091.     { Run down the list }
  1092.     for i := 0 to Items.Count - 1 do
  1093.     begin
  1094.       { Create a new temporary icon }
  1095.       TempIcon := TIcon.Create;
  1096.       { Call the custom DRWS routine to get icon for a file }
  1097.       GetIconForFile( Items[ i ] , TempIcon );
  1098.       { Put the icon on the bitmap for the picture via draw }
  1099.       { Note 1 , 1 due to bug in Draw?                      }
  1100.       TempPicture.Bitmap.Canvas.Draw( 1 , 1 , TempIcon );
  1101.       { Create a temporary bitmap }
  1102.       TempBmp := TBitmap.Create;
  1103.       { Set its width to those of the previous object's bitmaps }
  1104.       TempBmp.Width := 16;
  1105.       TempBmp.Height := 15;
  1106.       { Resize the icon's bitmap to the smaller size with stretchdraw }
  1107.       TempBmp.Canvas.StretchDraw( Rect( 1 , 1 , 15 , 14 ) ,
  1108.        TempPicture.Bitmap );
  1109.       { Set the Objects list to the bitmap }
  1110.       Items.Objects[ i ] := TempBmp;
  1111.       { Free the icon each iteration; don't free the TempBmp as list does }
  1112.       TempIcon.Free;
  1113.     end;
  1114.     { Free the TPicture exchange element }
  1115.     TempPicture.Free;
  1116.     {------------------------ end custom code --------------------------------}
  1117.     Change;
  1118.   end;
  1119. end;
  1120.  
  1121. { Use this to respond to dbl-clicking FLB filename }
  1122. procedure TIconFileListBox.TheDblClick(Sender: TObject);
  1123. begin
  1124.   { Call shellexec as a wrapper around ShellExecute API call }
  1125.   { False indicates failure, signal error                    }
  1126.   if not ShellExec( ExpandFileName( Items[ ItemIndex ] ), '' , '', false ,
  1127.    SW_SHOWNORMAL , false ) then MessageDlg('Could not Shell out to ' +
  1128.     Items[ ItemIndex ] , mtError, [mbOK], 0);
  1129. end;
  1130.  
  1131. { Create method for FIP                                }
  1132. constructor TIconFileListBox.Create( AOwner : TComponent );
  1133. begin
  1134.   { call inherited -- VITAL! }
  1135.   inherited Create( AOwner );
  1136.   { set the mouse method }
  1137.   OnDblClick := TheDblClick;
  1138. end;
  1139.  
  1140. { Create method for FIP                                }
  1141. constructor TFileIconPanel.Create( AOwner : TComponent );
  1142. begin
  1143.   { call inherited -- VITAL! }
  1144.   inherited Create( AOwner );
  1145.   { create icon and label components, making self owner/displayer }
  1146.   FTheIcon := TIcon.Create;
  1147.   FTheLabel := TLabel.Create( Self );
  1148.   FThelabel.Parent := Self;
  1149.   { Set own and labels mouse methods to stored methods }
  1150.   OnMouseUp := TheMouseUp;
  1151.   OnMouseDown := TheMouseDown;
  1152.   OnDragOver := TheDragOver;
  1153.   OnDragDrop := TheDragDrop;
  1154.   { Set alignment and autosize properties of the label }
  1155.   FTheLabel.Autosize := false;
  1156.   FTheLabel.Alignment := taCenter;
  1157.   { Set selected to false }
  1158.   Selected := false;
  1159. end;
  1160.  
  1161. procedure TFileIconPanel.WMLButtonDblClk(var Message: TWMLButtonDblClk);
  1162. var CurrentDirectory : String;    { Use to store dirs }
  1163.     TheDrive         : String;    { Get drive letter  }
  1164.     WhichDrive       : Integer;   { Get drive number  }
  1165.     ErrorCheck       : Integer;
  1166.     TheFWB           : TFileWorkBench;
  1167. begin
  1168.   { Create FileWorkBench for later use }
  1169.   TheFWB := TFileWorkBench.Create( Self );
  1170.   { Check for label or FIP sender }
  1171.   if FTheLabel.Caption = '..' then
  1172.   begin { deal with backup request }
  1173.     { Change to new directory }
  1174.     TheFWB.ChangeTheDirectory( '..' );
  1175.     { Call special method due to SendMessage problem! }
  1176.     TFileIconPanelScrollBox( Parent ).Update;
  1177.   end
  1178.   else
  1179.   begin
  1180.     { Check for DRIVE id in name }
  1181.     if Pos( 'DRIVE' , FTheName ) <> 0 then
  1182.     begin { Double Click on a Drive Icon }
  1183.       { Pull out the letter from name }
  1184.       TheDrive := Copy( FtheName , 7 , 1 );
  1185.       { Convert it to a number }
  1186.       WhichDrive := ( Ord( TheDrive[ 1 ] ) - Ord( 'A' )) + 1;
  1187.       TheFWB.ChangeTheDriveAndDirectory( WhichDrive );
  1188.       { Call special method due to SendMessage problem! }
  1189.       TFileIconPanelScrollBox( Parent ).Update;
  1190.     end
  1191.     else
  1192.     begin { Double click on a dir/file icon }
  1193.       if (( FileGetAttr( FTheName ) and faDirectory ) = faDirectory ) then
  1194.       begin { A directory, change to it }
  1195.         { Since full path in name, simply change to it! }
  1196.         TheFWB.ChangeTheDirectory( FTheName );
  1197.         { Call special method due to SendMessage problem! }
  1198.         TFileIconPanelScrollBox( Parent ).Update;
  1199.       end
  1200.       else
  1201.       begin { A file; attempt to shellexecute it }
  1202.         { Call shellexec as a wrapper around ShellExecute API call }
  1203.         { False indicates failure, signal error                    }
  1204.         if not ShellExec( FTheName , '' , '', false , SW_SHOWNORMAL , false )
  1205.          then MessageDlg('Could not Shell out to ' + FTheName , mtError,
  1206.           [mbOK], 0);
  1207.       end;
  1208.     end;
  1209.   end;
  1210.   TheFWB.Free; { This prevents resource leak }
  1211. end;
  1212.  
  1213. { Initialization method for FIP                                         }
  1214. procedure TFileIconPanel.Initialize( PanelX              ,
  1215.                                      PanelY              ,
  1216.                                      PanelWidth          ,
  1217.                                      PanelHeight         ,
  1218.                                      PanelBevelWidth     ,
  1219.                                      LabelFontSize         : Integer;
  1220.                                      PanelColor          ,
  1221.                                      PanelHighlightColor ,
  1222.                                      PanelShadowColor    ,
  1223.                                      LabelTextColor        : TColor;
  1224.                                      TheFilename         ,
  1225.                                      LabelFontName         : String;
  1226.                                      LabelFontStyle        : TFontStyles;
  1227.                                      ExtraData             : Integer );
  1228.  
  1229. var TheLabelHeight ,             { Holder for label pixel height }
  1230.     TheLabelWidth    : Integer;  { Holder for label pixel width  }
  1231.     TheOtherPChar    : PChar;    { Windows ASCIIZ string         }
  1232. begin
  1233.   { Set the basic properties based on imported parameters }
  1234.   Left := PanelX;
  1235.   Top := PanelY;
  1236.   Width := PanelWidth;
  1237.   Height := PanelHeight;
  1238.   Color := PanelColor;
  1239.   BevelWidth := PanelBevelWidth;
  1240.   FHighlightColor := PanelHighlightColor;
  1241.   FShadowColor := PanelShadowColor;
  1242.   FTheName := TheFilename;
  1243.   { If the ExtraData field is non-0 then a drive is being sent in }
  1244.   if ExtraData <> 0 then
  1245.   begin
  1246.     { Use the data field value to determine which icon to get from RES file }
  1247.     case ExtraData of
  1248.       1 : begin
  1249.             GetMem( TheOtherPChar , 255 );
  1250.             StrPCopy( TheOtherPChar , 'FLOPPY35' );
  1251.             FTheIcon.Handle := LoadIcon( hInstance , TheOtherPChar );
  1252.             FreeMem( TheOtherPChar , 255 );
  1253.           end;
  1254.       2 : begin
  1255.             GetMem( TheOtherPChar , 255 );
  1256.             StrPCopy( TheOtherPChar , 'FIXEDHD' );
  1257.             FTheIcon.Handle := LoadIcon( hInstance , TheOtherPChar );
  1258.             FreeMem( TheOtherPChar , 255 );
  1259.           end;
  1260.       3 : begin
  1261.             GetMem( TheOtherPChar , 255 );
  1262.             StrPCopy( TheOtherPChar , 'NETWORKHD' );
  1263.             FTheIcon.Handle := LoadIcon( hInstance , TheOtherPChar );
  1264.             FreeMem( TheOtherPChar , 255 );
  1265.           end;
  1266.       4 : begin
  1267.             GetMem( TheOtherPChar , 255 );
  1268.             StrPCopy( TheOtherPChar , 'CDROM' );
  1269.             FTheIcon.Handle := LoadIcon( hInstance , TheOtherPChar );
  1270.             FreeMem( TheOtherPChar , 255 );
  1271.           end;
  1272.       5 : begin
  1273.             GetMem( TheOtherPChar , 255 );
  1274.             StrPCopy( TheOtherPChar , 'RAM' );
  1275.             FTheIcon.Handle := LoadIcon( hInstance , TheOtherPChar );
  1276.             FreeMem( TheOtherPChar , 255 );
  1277.           end;
  1278.     end;
  1279.     { The FileNme property is already set up for the caption; use directly }
  1280.     FTheLabel.Caption := TheFilename;
  1281.     { Set up the hint for later use (make sure to set ShowHint) }
  1282.     Hint := 'Change to ' + TheFileName;
  1283.     ShowHint := true;
  1284.     { Set up all imported label properties and center it for drawing }
  1285.     with FTheLabel do
  1286.     begin
  1287.       Font.Name := LabelFontName;
  1288.       Font.Size := LabelFontSize;
  1289.       Font.Style := LabelFontStyle;
  1290.       Font.Color := LabelTextColor;
  1291.       Canvas.Brush.Color := PanelColor;
  1292.       Canvas.Font := Font;
  1293.       TheLabelHeight := Canvas.Textheight( Caption ) + 4;
  1294.       TheLabelWidth := Canvas.Textwidth( Caption ) + 4;
  1295.       Left := (( Self.Width - TheLabelWidth ) div 2 ) + 1;
  1296.       Top := ((( Round( Self.Height * 0.25 ) - 6 ) - TheLabelHeight) div 2) + 1;
  1297.       Top := Top + Round( Self.Height * 0.75 );
  1298.       Height := TheLabelHeight;
  1299.       Width := TheLabelWidth;
  1300.     end;
  1301.   end
  1302.   else
  1303.   begin
  1304.     { A file or directory has been sent in; use GetIconForFile to obtain an }
  1305.     { icon either from the file, its owner, or a RES file default.          }
  1306.     GetIconForFile( FTheName , FTheIcon );
  1307.     { Check for the Backup caption and set it specially }
  1308.     if ExtractfileName( FThename ) = '..' then
  1309.     begin
  1310.       FTheLabel.Caption := '..';
  1311.       Hint := 'Up One Level';
  1312.     end
  1313.     else
  1314.     begin
  1315.       { Otherwise just get the filename for the label caption }
  1316.       { And the full path for the hint (used later.)          }
  1317.       FTheLabel.caption := ExtractFileName( UpperCase( FTheName ));
  1318.       Hint := FTheName;
  1319.     end;
  1320.     { Activate showhint so hints are seen }
  1321.     ShowHint := true;
  1322.     { Set label properties with imported values and center for display }
  1323.     with FTheLabel do
  1324.     begin
  1325.       Font.Name := LabelFontName;
  1326.       Font.Size := LabelFontSize;
  1327.       Font.Style := LabelFontStyle;
  1328.       Font.Color := LabelTextColor;
  1329.       Canvas.Brush.Color := PanelColor;
  1330.       Canvas.Font := Font;
  1331.       TheLabelHeight := Canvas.Textheight( Caption ) + 4;
  1332.       TheLabelWidth := Canvas.Textwidth( Caption ) + 4;
  1333.       Left := (( Self.Width - TheLabelWidth ) div 2 ) + 1;
  1334.       Top := ((( Round( Self.Height * 0.25 ) - 6 ) - TheLabelHeight) div 2) + 1;
  1335.       Top := Top + Round( Self.Height * 0.75 );
  1336.       Height := TheLabelHeight;
  1337.       Width := TheLabelWidth;
  1338.     end;
  1339.   end;
  1340. end;
  1341.  
  1342. { Destroy method for FIP }
  1343. destructor TFileIconPanel.Destroy;
  1344. begin
  1345.   { free component resources }
  1346.   FTheIcon.Free;
  1347.   FTheLabel.Free;
  1348.   { call inherited -- VITAL! }
  1349.   inherited Destroy;
  1350. end;
  1351.  
  1352. { Mousedown method for FIP; used to allow dragging }
  1353. procedure TFileIconPanel.TheMouseDown(Sender: TObject;
  1354.   Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  1355. begin
  1356.   { Begin a conditional drag operation (false allows timer) }
  1357.   TheIOManager.WhichButton := Button;
  1358.   TheIOManager.WhichState := Shift;
  1359.   if button <> mbRight then BeginDrag( false );
  1360.   { Currently ignore drive clicks }
  1361.   if Pos( 'DRIVE' , FTheName ) > 0 then exit;
  1362.   { Flip status of bevels }
  1363.   if BevelOuter = bvRaised then BevelOuter := bvLowered else
  1364.    BevelOuter := bvRaised;
  1365.   { Flip selected variable }
  1366.   Selected := not Selected;
  1367.   { Set redisplay }
  1368. end;
  1369.  
  1370. { Mouseup Method for FIP; used to allow dragging }
  1371. procedure TFileIconPanel.TheMouseUp(Sender: TObject;
  1372.   Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  1373. begin
  1374.   { End a drag operation without dropping; if dragged OK }
  1375.   { already handled.                                     }
  1376.   {EndDrag( false );}
  1377.   { If the right button is clicked, perform magic! }
  1378.   if Button = mbRight then
  1379.    TCCFileMgrForm( TFileIconPanelScrollbox( Parent ).
  1380.     TheParentForm ).BitBtn6Click( Self );
  1381.   { Redisplay on general principles }
  1382.   Invalidate;
  1383. end;
  1384.  
  1385. { Use this to generically OK DnD from FIPs }
  1386. procedure TFileIconPanel.TheDragOver(Sender, Source: TObject; X,
  1387.   Y: Integer; State: TDragState; var Accept: Boolean);
  1388. begin
  1389.   { Only accept from FileIconPanel components }
  1390.   if Source is TFileIconPanel then Accept := true else Accept := false;
  1391. end;
  1392.  
  1393. { Use this to accept Drag and Drop from other FIPs }
  1394. procedure TFileIconPanel.TheDragDrop(Sender, Source: TObject; X,
  1395.   Y: Integer);
  1396. var CurrentName ,                 { Holds work name}
  1397.     TheOldString : String;        { Holds Dir      }
  1398.     TargetDir    : String;        { target of op   }
  1399.     TheResult       : Integer;    { Modal res hold }
  1400.     SourceDirectory,
  1401.     TargetDirectory,
  1402.     CurrentDirectory : String;    { Use to store dirs }
  1403.     TheDrive         : String;    { Get drive letter  }
  1404.     WhichDrive       : Integer;   { Get drive number  }
  1405.     ErrorCheck       : Integer;
  1406.     TheFWB           : TFileWorkBench;
  1407.     ThePosition : Integer;
  1408.     Finished : Boolean;
  1409.     TheFIPSB : TFileIconPanelScrollBox;
  1410. begin
  1411.   { If drop target is .. then ignore }
  1412.   if FTheLabel.Caption = '..' then exit;
  1413.   { Likewise ignore Dnd from drive icons }
  1414.   if Pos( 'DRIVE' , TFileIconPanel( Source ).FtheName ) > 0 then exit;
  1415.   { Obtain the parent of the source FIP; may not be self }
  1416.   TheFIPSB := TFileIconPanelScrollBox( TFileIconPanel( Source ).Parent );
  1417.   { Obtain source directory either as Dir or filepath }
  1418.   if (( FileGetAttr( TFileIconPanel( Source ).FTheName )
  1419.    and faDirectory ) = faDirectory ) then
  1420.   begin  { Directory; take whole path }
  1421.     SourceDirectory := TFileIconPanel( Source ).FTheName;
  1422.   end
  1423.   else
  1424.   begin { File; get pathname }
  1425.     SourceDirectory := ExtractFilePath( TFileIconPanel( Source ).FTheName );
  1426.   end;
  1427.   Sourcedirectory := TheFIPSB.TheFWB.ForceTrailingBackSlash( SourceDirectory );
  1428.   if Pos( 'DRIVE' , FTheName ) > 0 then
  1429.   begin { Drop onto a drive icon; perform action to its default dir }
  1430.     { Pull out the letter from name }
  1431.     TheDrive := Copy( FtheName , 7 , 1 );
  1432.     { Convert it to a number }
  1433.     WhichDrive := ( Ord( TheDrive[ 1 ] ) - Ord( 'A' )) + 1;
  1434.     { Determine the target directory and drive }
  1435.     GetDir( WhichDrive , TargetDirectory );
  1436.     TargetDirectory := TheFIPSB.TheFWB.ForceTrailingbackSlash( TargetDirectory );
  1437.     { Check for shift to operate on all selections }
  1438.     if TheIOManager.WasSHIFTPressed then
  1439.     begin { Operate on all selections }
  1440.       { Obtain the parent directory of the FIP dragged over }
  1441.       SourceDirectory := ExtractFilePath( TFileIconPanel( Source ).FTheName );
  1442.       SourceDirectory := TheFIPSB.TheFWB.ForceTrailingBackslash( SourceDirectory );
  1443.       { If SourceDir subset of TargetDir then abort; recursive failure }
  1444.       if Pos( SourceDirectory , TargetDirectory ) > 0 then
  1445.       begin
  1446.         MessageDlg( 'Cannot drag to same directory!',mtError,[mbOK],0 );
  1447.         exit;
  1448.       end;
  1449.       if TargetDirectory[ 1 ] <> SourceDirectory[ 1 ] then
  1450.       begin { Copy to different drives }
  1451.         if TheIOManager.WasALTPressed then
  1452.         begin { ALT overrides and does move }
  1453.           { Set up to get all current selections }
  1454.           ThePosition := 1;
  1455.           finished := false;
  1456.           while not finished do
  1457.           begin
  1458.             CurrentName := TheFIPSB.GetNextSelection( SourceDirectory ,
  1459.                    ThePosition );
  1460.             { If returns blank string then out of selections }
  1461.             if CurrentName = '' then finished := true else
  1462.             begin
  1463.               { If a directory signal error }
  1464.               if (( FileGetAttr( CurrentName ) and faDirectory ) = faDirectory ) then
  1465.               begin
  1466.                 if MessageDlg( 'Move Directory ' + CurrentName + ' to ' +
  1467.                  TargetDirectory + '?' , mtConfirmation , mbYesNoCancel , 0 ) = mrYes then
  1468.                   TheFIPSB.TheFWB.RecursivelyMoveDirectory( CurrentName ,
  1469.                    TargetDirectory );
  1470.               end
  1471.               else
  1472.               begin
  1473.                 TheFIPSB.TheFWB.MoveTheFile( CurrentName , TargetDirectory );
  1474.               end;
  1475.             end;
  1476.             { Reset to normal cursor }
  1477.             Screen.Cursor := crDefault;
  1478.           end;
  1479.         end
  1480.         else
  1481.         begin { Default is to do copy like file manager }
  1482.           { Set up to get all current selections }
  1483.           ThePosition := 1;
  1484.           finished := false;
  1485.           while not finished do
  1486.           begin
  1487.              CurrentName := TheFIPSB.GetNextSelection( SourceDirectory ,
  1488.                    ThePosition );
  1489.             { If returns blank string then out of selections }
  1490.             if CurrentName = '' then finished := true else
  1491.             begin
  1492.               { If a directory signal error }
  1493.               if (( FileGetAttr( CurrentName ) and faDirectory ) = faDirectory ) then
  1494.               begin
  1495.                 if MessageDlg( 'Copy Directory ' + CurrentName + ' to ' +
  1496.                  TargetDirectory + '?' , mtConfirmation , mbYesNoCancel , 0 ) = mrYes then
  1497.                   TheFIPSB.TheFWB.RecursivelyCopyDirectory( CurrentName ,
  1498.                    TargetDirectory );
  1499.               end
  1500.               else
  1501.               begin
  1502.                 TheFIPSB.TheFWB.CopyTheFile( CurrentName , TargetDirectory );
  1503.               end;
  1504.             end;
  1505.             { Reset to normal cursor }
  1506.             Screen.Cursor := crDefault;
  1507.           end;
  1508.         end;
  1509.       end
  1510.       else
  1511.       begin { Copy to same drive }
  1512.         if TheIOManager.WasCTRLPressed then
  1513.         begin { CTRL overrides and does copy }
  1514.           { Set up to get all current selections }
  1515.           ThePosition := 1;
  1516.           finished := false;
  1517.           while not finished do
  1518.           begin
  1519.             CurrentName := TheFIPSB.GetNextSelection( SourceDirectory ,
  1520.                    ThePosition );
  1521.             { If returns blank string then out of selections }
  1522.             if CurrentName = '' then finished := true else
  1523.             begin
  1524.               { If a directory signal error }
  1525.               if (( FileGetAttr( CurrentName ) and faDirectory ) = faDirectory ) then
  1526.               begin
  1527.                 if MessageDlg( 'Copy Directory ' + CurrentName + ' to ' +
  1528.                  TargetDirectory + '?' , mtConfirmation , mbYesNoCancel , 0 ) = mrYes then
  1529.                   TheFIPSB.TheFWB.RecursivelyCopyDirectory( CurrentName ,
  1530.                    TargetDirectory );
  1531.               end
  1532.               else
  1533.               begin
  1534.                 TheFIPSB.TheFWB.CopyTheFile( CurrentName , TargetDirectory );
  1535.               end;
  1536.             end;
  1537.             { Reset to normal cursor }
  1538.             Screen.Cursor := crDefault;
  1539.           end;
  1540.         end
  1541.         else
  1542.         begin { Default is to do move like file manager }
  1543.           { Set up to get all current selections }
  1544.           ThePosition := 1;
  1545.           finished := false;
  1546.           while not finished do
  1547.           begin
  1548.             CurrentName := TheFIPSB.GetNextSelection( SourceDirectory ,
  1549.                    ThePosition );
  1550.             { If returns blank string then out of selections }
  1551.             if CurrentName = '' then finished := true else
  1552.             begin
  1553.               { If a directory signal error }
  1554.               if (( FileGetAttr( CurrentName ) and faDirectory ) = faDirectory ) then
  1555.               begin
  1556.                 if MessageDlg( 'Move Directory ' + CurrentName + ' to ' +
  1557.                  TargetDirectory + '?' , mtConfirmation , mbYesNoCancel , 0 ) = mrYes then
  1558.                   TheFIPSB.TheFWB.RecursivelyMoveDirectory( CurrentName ,
  1559.                    TargetDirectory );
  1560.               end
  1561.               else
  1562.               begin
  1563.                 TheFIPSB.TheFWB.MoveTheFile( CurrentName , TargetDirectory );
  1564.               end;
  1565.             end;
  1566.             { Reset to normal cursor }
  1567.             Screen.Cursor := crDefault;
  1568.           end;
  1569.         end;
  1570.       end;
  1571.     end
  1572.     else
  1573.     begin { Operate on only source }
  1574.       if TargetDirectory[ 1 ] <> SourceDirectory[ 1 ] then
  1575.       begin { Copy to different drives }
  1576.         if TheIOManager.WasALTPressed then
  1577.         begin { ALT overrides and does move }
  1578.           with Source as TFileIconPanel do
  1579.           begin
  1580.             if MessageDlg( 'Move ' + FTheName + ' to ' +
  1581.              TargetDirectory + '?' , mtConfirmation , mbYesNoCancel , 0 ) = mrYes then
  1582.               TheFIPSB.TheFWB.MoveTheFile( FTheName , TargetDirectory );
  1583.           end;
  1584.         end
  1585.         else
  1586.         begin { Default is to do copy like file manager }
  1587.           with Source as TFileIconPanel do
  1588.           begin
  1589.             if MessageDlg( 'Copy ' + FTheName + ' to ' +
  1590.              TargetDirectory + '?' , mtConfirmation , mbYesNoCancel , 0 ) = mrYes then
  1591.               TheFIPSB.TheFWB.CopyTheFile( FtheName , TargetDirectory );
  1592.           end;
  1593.         end;
  1594.       end
  1595.       else
  1596.       begin { Copy to same drive }
  1597.         if TheIOManager.WasCTRLPressed then
  1598.         begin { CTRL overrides and does copy }
  1599.           with Source as TFileIconPanel do
  1600.           begin
  1601.             if MessageDlg( 'Copy ' + FTheName + ' to ' +
  1602.              TargetDirectory + '?' , mtConfirmation , mbYesNoCancel , 0 ) = mrYes then
  1603.               TheFIPSB.TheFWB.CopyTheFile( FTheName , TargetDirectory );
  1604.           end;
  1605.         end
  1606.         else
  1607.         begin { Default is to do move like file manager }
  1608.           with Source as TFileIconPanel do
  1609.           begin
  1610.             if MessageDlg( 'Move ' + FTheName + ' to ' +
  1611.              TargetDirectory + '?' , mtConfirmation , mbYesNoCancel , 0 ) = mrYes then
  1612.              TheFIPSB.TheFWB.MoveTheFile( FtheName , TargetDirectory );
  1613.           end;
  1614.         end;
  1615.       end;
  1616.     end;
  1617.   end
  1618.   else
  1619.   begin { Drop onto dir or file icon }
  1620.     if (( FileGetAttr( FTheName ) and faDirectory ) = faDirectory ) then
  1621.     begin { Drop onto a directory; use its path as target }
  1622.       TargetDirectory := FTheName;
  1623.     end
  1624.     else
  1625.     begin { Drop onto a file; use its parent as target }
  1626.       TargetDirectory := ExtractFilePath( FTheName );
  1627.     end;
  1628.     Targetdirectory := TheFIPSB.TheFWB.ForceTrailingbackslash( TargetDirectory );
  1629.     { Check for shift to operate on all selections }
  1630.     if TheIOManager.WasSHIFTPressed then
  1631.     begin { Operate on all selections }
  1632.       { Obtain the parent directory of the FIP dragged over }
  1633.       SourceDirectory := ExtractFilePath( TFileIconPanel( Source ).FTheName );
  1634.       SourceDirectory := TheFIPSB.TheFWB.ForceTrailingBackslash( SourceDirectory );
  1635.       { If SourceDir subset of TargetDir then abort; recursive failure }
  1636.       if Pos( SourceDirectory , TargetDirectory ) > 0 then
  1637.       begin
  1638.         MessageDlg( 'Cannot drag to same directory!',mtError,[mbOK],0 );
  1639.         exit;
  1640.       end;
  1641.       if TargetDirectory[ 1 ] <> SourceDirectory[ 1 ] then
  1642.       begin { Copy to different drives }
  1643.         if TheIOManager.WasALTPressed then
  1644.         begin { ALT overrides and does move }
  1645.           { Set up to get all current selections }
  1646.           ThePosition := 1;
  1647.           finished := false;
  1648.           while not finished do
  1649.           begin
  1650.              CurrentName := TheFIPSB.GetNextSelection( SourceDirectory ,
  1651.                    ThePosition );
  1652.             { If returns blank string then out of selections }
  1653.             if CurrentName = '' then finished := true else
  1654.             begin
  1655.               { If a directory signal error }
  1656.               if (( FileGetAttr( CurrentName ) and faDirectory ) = faDirectory ) then
  1657.               begin
  1658.                 if MessageDlg( 'Move Directory ' + CurrentName + ' to ' +
  1659.                  TargetDirectory + '?' , mtConfirmation , mbYesNoCancel , 0 ) = mrYes then
  1660.                   TheFIPSB.TheFWB.RecursivelyMoveDirectory( CurrentName ,
  1661.                    TargetDirectory );
  1662.               end
  1663.               else
  1664.               begin
  1665.                 TheFIPSB.TheFWB.MoveTheFile( CurrentName , TargetDirectory );
  1666.               end;
  1667.             end;
  1668.             { Reset to normal cursor }
  1669.             Screen.Cursor := crDefault;
  1670.           end;
  1671.         end
  1672.         else
  1673.         begin { Default is to do copy like file manager }
  1674.           { Set up to get all current selections }
  1675.           ThePosition := 1;
  1676.           finished := false;
  1677.           while not finished do
  1678.           begin
  1679.             CurrentName := TheFIPSB.GetNextSelection( SourceDirectory ,
  1680.                    ThePosition );
  1681.             { If returns blank string then out of selections }
  1682.             if CurrentName = '' then finished := true else
  1683.             begin
  1684.               { If a directory signal error }
  1685.               if (( FileGetAttr( CurrentName ) and faDirectory ) = faDirectory ) then
  1686.               begin
  1687.                 if MessageDlg( 'Copy Directory ' + CurrentName + ' to ' +
  1688.                  TargetDirectory + '?' , mtConfirmation , mbYesNoCancel , 0 ) = mrYes then
  1689.                   TheFIPSB.TheFWB.RecursivelyCopyDirectory( CurrentName ,
  1690.                    TargetDirectory );
  1691.               end
  1692.               else
  1693.               begin
  1694.                 TheFIPSB.TheFWB.CopyTheFile( CurrentName , TargetDirectory );
  1695.               end;
  1696.             end;
  1697.             { Reset to normal cursor }
  1698.             Screen.Cursor := crDefault;
  1699.           end;
  1700.         end;
  1701.       end
  1702.       else
  1703.       begin { Copy to same drive }
  1704.         if TheIOManager.WasCTRLPressed then
  1705.         begin { CTRL overrides and does copy }
  1706.           { Set up to get all current selections }
  1707.           ThePosition := 1;
  1708.           finished := false;
  1709.           while not finished do
  1710.           begin
  1711.             { Call generic file getting routine based on current view}
  1712.              CurrentName := TheFIPSB.GetNextSelection( SourceDirectory ,
  1713.                    ThePosition );
  1714.             { If returns blank string then out of selections }
  1715.             if CurrentName = '' then finished := true else
  1716.             begin
  1717.               { If a directory signal error }
  1718.               if (( FileGetAttr( CurrentName ) and faDirectory ) = faDirectory ) then
  1719.               begin
  1720.                 if MessageDlg( 'Copy Directory ' + CurrentName + ' to ' +
  1721.                  TargetDirectory + '?' , mtConfirmation , mbYesNoCancel , 0 ) = mrYes then
  1722.                   TheFIPSB.TheFWB.RecursivelyCopyDirectory( CurrentName ,
  1723.                    TargetDirectory );
  1724.               end
  1725.               else
  1726.               begin
  1727.                 TheFIPSB.TheFWB.CopyTheFile( CurrentName , TargetDirectory );
  1728.               end;
  1729.             end;
  1730.             { Reset to normal cursor }
  1731.             Screen.Cursor := crDefault;
  1732.           end;
  1733.         end
  1734.         else
  1735.         begin { Default is to do move like file manager }
  1736.           { Set up to get all current selections }
  1737.           ThePosition := 1;
  1738.           finished := false;
  1739.           while not finished do
  1740.           begin
  1741.             { Call generic file getting routine based on current view}
  1742.               CurrentName := TheFIPSB.GetNextSelection( SourceDirectory ,
  1743.                    ThePosition );
  1744.             { If returns blank string then out of selections }
  1745.             if CurrentName = '' then finished := true else
  1746.             begin
  1747.               { If a directory signal error }
  1748.               if (( FileGetAttr( CurrentName ) and faDirectory ) = faDirectory ) then
  1749.               begin
  1750.                 if MessageDlg( 'Move Directory ' + CurrentName + ' to ' +
  1751.                  TargetDirectory + '?' , mtConfirmation , mbYesNoCancel , 0 ) = mrYes then
  1752.                   TheFIPSB.TheFWB.RecursivelyMoveDirectory( CurrentName ,
  1753.                    TargetDirectory );
  1754.               end
  1755.               else
  1756.               begin
  1757.                 TheFIPSB.TheFWB.MoveTheFile( CurrentName , TargetDirectory );
  1758.               end;
  1759.             end;
  1760.             { Reset to normal cursor }
  1761.             Screen.Cursor := crDefault;
  1762.           end;
  1763.         end;
  1764.       end;
  1765.     end
  1766.     else
  1767.     begin { Operate on only source }
  1768.       if TargetDirectory[ 1 ] <> SourceDirectory[ 1 ] then
  1769.       begin { Copy to different drives }
  1770.         if TheIOManager.WasALTPressed then
  1771.         begin { ALT overrides and does move }
  1772.           with Source as TFileIconPanel do
  1773.           begin
  1774.             if (( FileGetAttr( FTheName ) and faDirectory ) = faDirectory ) then
  1775.             begin
  1776.               if MessageDlg( 'Move Directory ' + FTheName + ' to ' +
  1777.                TargetDirectory + '?' , mtConfirmation , mbYesNoCancel , 0 ) = mrYes then
  1778.                 TheFIPSB.TheFWB.RecursivelyMoveDirectory( FtheName ,
  1779.                  TargetDirectory );
  1780.             end
  1781.             else
  1782.             begin
  1783.               if MessageDlg( 'Move ' + FTheName + ' to ' +
  1784.                TargetDirectory + '?' , mtConfirmation , mbYesNoCancel , 0 ) = mrYes then
  1785.                 TheFIPSB.TheFWB.MoveTheFile( FTheName , TargetDirectory );
  1786.             end;
  1787.           end;
  1788.         end
  1789.         else
  1790.         begin { Default is to do copy like file manager }
  1791.           with Source as TFileIconPanel do
  1792.           begin
  1793.             if (( FileGetAttr( FTheName ) and faDirectory ) = faDirectory ) then
  1794.             begin
  1795.               if MessageDlg( 'Copy Directory ' + FtheName + ' to ' +
  1796.                TargetDirectory + '?' , mtConfirmation , mbYesNoCancel , 0 ) = mrYes then
  1797.                 TheFIPSB.TheFWB.RecursivelyCopyDirectory( FtheName ,
  1798.                  TargetDirectory );
  1799.             end
  1800.             else
  1801.             begin
  1802.               if MessageDlg( 'Copy ' + FTheName + ' to ' +
  1803.                TargetDirectory + '?' , mtConfirmation , mbYesNoCancel , 0 ) = mrYes then
  1804.                 TheFIPSB.TheFWB.CopyTheFile( FTheName , TargetDirectory );
  1805.             end;
  1806.           end;
  1807.         end;
  1808.       end
  1809.       else
  1810.       begin { Copy to same drive }
  1811.         if TheIOManager.WasCTRLPressed then
  1812.         begin { CTRL overrides and does copy }
  1813.           with Source as TFileIconPanel do
  1814.           begin
  1815.             if (( FileGetAttr( FTheName ) and faDirectory ) = faDirectory ) then
  1816.             begin
  1817.               if MessageDlg( 'Copy Directory ' + FtheName + ' to ' +
  1818.                TargetDirectory + '?' , mtConfirmation , mbYesNoCancel , 0 ) = mrYes then
  1819.                 TheFIPSB.TheFWB.RecursivelyCopyDirectory( FtheName ,
  1820.                  TargetDirectory );
  1821.             end
  1822.             else
  1823.             begin
  1824.               if MessageDlg( 'Copy ' + FTheName + ' to ' +
  1825.                TargetDirectory + '?' , mtConfirmation , mbYesNoCancel , 0 ) = mrYes then
  1826.                 TheFIPSB.TheFWB.CopyTheFile( FTheName , TargetDirectory );
  1827.             end;
  1828.           end;
  1829.         end
  1830.         else
  1831.         begin { Default is to do move like file manager }
  1832.           with Source as TFileIconPanel do
  1833.           begin
  1834.             if (( FileGetAttr( FTheName ) and faDirectory ) = faDirectory ) then
  1835.             begin
  1836.               if MessageDlg( 'Move Directory ' + FtheName + ' to ' +
  1837.                TargetDirectory + '?' , mtConfirmation , mbYesNoCancel , 0 ) = mrYes then
  1838.                 TheFIPSB.TheFWB.RecursivelyMoveDirectory( FtheName ,
  1839.                  TargetDirectory );
  1840.             end
  1841.             else
  1842.             begin
  1843.               if MessageDlg( 'Move ' + FTheName + ' to ' +
  1844.                TargetDirectory + '?' , mtConfirmation , mbYesNoCancel , 0 ) = mrYes then
  1845.                 TheFIPSB.TheFWB.MoveTheFile( FTheName , TargetDirectory );
  1846.             end;
  1847.           end;
  1848.         end;
  1849.       end;
  1850.     end;
  1851.   end;
  1852.   { Call special method due to SendMessage problem! }
  1853.   TFileIconPanelScrollBox( TFileIconPanel( Source ).Parent ).Update;
  1854.   TFileIconPanelScrollBox( Parent ).Update;
  1855. end;
  1856.  
  1857. { Paint method for FIP; overrides normal paint }
  1858. procedure TFileIconPanel.Paint;
  1859. var
  1860.   TheOtherRect   : TRect;   { Holds clientrect   }
  1861.   TopColor     ,            { Holds bright color }
  1862.   BottomColor    : TColor;  { Holds dark color   }
  1863.  
  1864. { These methods are from Borland Intl., copyright 1995 }
  1865. procedure Frame3D(    Canvas       : TCanvas;
  1866.                   var TheRect      : TRect;
  1867.                       TopColor   ,
  1868.                       BottomColor  : TColor;
  1869.                       Width        : Integer );
  1870.  
  1871. procedure DoRect;
  1872. var
  1873.   TopRight, BottomLeft: TPoint;
  1874. begin
  1875.   with Canvas, TheRect do
  1876.   begin
  1877.     TopRight.X := Right;
  1878.     TopRight.Y := Top;
  1879.     BottomLeft.X := Left;
  1880.     BottomLeft.Y := Bottom;
  1881.     Pen.Color := TopColor;
  1882.     PolyLine([BottomLeft, TopLeft, TopRight]);
  1883.     Pen.Color := BottomColor;
  1884.     Dec(BottomLeft.X);
  1885.     PolyLine([TopRight, BottomRight, BottomLeft]);
  1886.   end;
  1887. end;
  1888.  
  1889. begin
  1890.   Canvas.Pen.Width := 1;
  1891.   Dec(TheRect.Bottom); Dec(TheRect.Right);
  1892.   while Width > 0 do
  1893.   begin
  1894.     Dec(Width);
  1895.     DoRect;
  1896.     InflateRect(TheRect, -1, -1);
  1897.   end;
  1898.   Inc(TheRect.Bottom); Inc(TheRect.Right);
  1899. end;
  1900.  
  1901. procedure AdjustColors(Bevel: TPanelBevel);
  1902. begin
  1903.   TopColor := FHighlightColor;
  1904.   if Bevel = bvLowered then TopColor := FShadowColor;
  1905.   BottomColor := FShadowColor;
  1906.   if Bevel = bvLowered then BottomColor := FHighlightColor;
  1907. end;
  1908.  
  1909. { Custom code begins here }
  1910. begin
  1911.   { Get the rectangle of the control with API/method call }
  1912.   TheOtherRect := GetClientRect;
  1913.   { draw basic rectangle with basic color }
  1914.   with Canvas do
  1915.   begin
  1916.     Brush.Color := Color;
  1917.     FillRect(TheOtherRect);
  1918.   end;
  1919.   { Set up for top "icon" frame  and draw it with frame3d }
  1920.   TheOtherRect.Right := Width;
  1921.   TheOtherRect.Bottom := Round( Height * 0.75 ) - 6 ;
  1922.   if BevelOuter <> bvNone then
  1923.   begin
  1924.     AdjustColors(BevelOuter);
  1925.     Frame3D(Canvas, TheOtherRect, TopColor, BottomColor, BevelWidth);
  1926.   end;
  1927.   Frame3D(Canvas, TheOtherRect, Color, Color, BorderWidth);
  1928.   if BevelInner <> bvNone then
  1929.   begin
  1930.     AdjustColors(BevelInner);
  1931.     Frame3D(Canvas, TheOtherRect, TopColor, BottomColor, BevelWidth);
  1932.   end;
  1933.   { Do the same for the lower "label" frame }
  1934.   TheOtherRect.Top := Round( Height * 0.75 ) - 5;
  1935.   TheOtherRect.Left := 0;
  1936.   TheOtherRect.Bottom := Height;
  1937.   TheOtherRect.Right := Width;
  1938.   if BevelOuter <> bvNone then
  1939.   begin
  1940.     AdjustColors(BevelOuter);
  1941.     Frame3D(Canvas, TheOtherRect, TopColor, BottomColor, BevelWidth);
  1942.   end;
  1943.   Frame3D(Canvas, TheOtherRect, Color, Color, BorderWidth);
  1944.   if BevelInner <> bvNone then
  1945.   begin
  1946.     AdjustColors(BevelInner);
  1947.     Frame3D(Canvas, TheOtherRect, TopColor, BottomColor, BevelWidth);
  1948.   end;
  1949.   { Then draw the icon using canvas draw method }
  1950.   Canvas.Draw( (( Width - 32 ) div 2 ) + 1 ,
  1951.   ((( Round( Height * 0.75 ) - 6 ) - 32 ) div 2 ) + 1 , FTheIcon );
  1952. end;
  1953.  
  1954. { This procedure clears a scrollbox of all FileIconPanels }
  1955. procedure TFileIconPanelScrollbox.ClearTheFIPs;
  1956. var Counter_1 : Integer;
  1957.     TheComponent : TComponent;
  1958. begin
  1959.   { Note that must use while loop since component count continually }
  1960.   { decreases as removes are made!                                  }
  1961.   while ComponentCount > 0 do
  1962.   begin
  1963.     { Save the component as a generic TComponent }
  1964.     TheComponent := Components[ 0 ];
  1965.     { Call removecomponent to pull it out of the owner list for sb }
  1966.     { This avoids GPF when freeing the sb.                         }
  1967.     RemoveComponent( Components[ 0 ]);
  1968.     if ControlCount > 0 then
  1969.      RemoveControl( Controls[ 0 ] );
  1970.     { Typecast the pointer and free it to release memory and res. }
  1971.     TheParentForm.InsertComponent( TheComponent );
  1972.   end;
  1973. end;
  1974.  
  1975. { This procedure scans for drives and obtains their type and creates file }
  1976. { icon panels to represent them.                                          }
  1977. procedure TFileIconPanelScrollBox.AddDriveIcons( var XCounter ,
  1978.            YCounter : Integer );
  1979. type
  1980.   { This if from filectrl unit; reproduce here for completeness }
  1981.   TDriveType = (dtUnknown, dtNoDrive, dtFloppy, dtFixed, dtNetwork, dtCDROM,
  1982.                 dtRAM);
  1983. var
  1984.   DrivePC         : array[0..256] of char;
  1985.   DriveNum        : Integer;         { Used to get next drive via DOS fn   }
  1986.   IconType        : Integer;         { Used to hold icon type (defacto dt) }
  1987.   DriveChar       : Char;            { Used to hold drive letter           }
  1988.   DriveType       : TDriveType;      { Used for set-valued drive type      }
  1989.   Finished        : Boolean;         { Loop flag                           }
  1990.   TheFIP          : TFileIconPanel;  { Generic FileIconPanel variable      }
  1991.   ButtonColor   ,                    { Main panel color                    }
  1992.   ButtonHLColor ,                    { Bright panel color                  }
  1993.   ButtonSColor  ,                    { Dark panel color                    }
  1994.   Textcolor       : TColor;          { Label text color                    }
  1995.  
  1996. (*{ This code is from the FileCtrl Unit; copyright Borland Intl 1995      }
  1997. { Check whether drive is a CD-ROM.  Returns True if MSCDEX is installed }
  1998. {  and the drive is using a CD driver                                   }
  1999.  
  2000. function IsCDROM(DriveNum: Integer): Boolean; assembler;
  2001. asm
  2002.   MOV   AX,1500h { look for MSCDEX }
  2003.   XOR   BX,BX
  2004.   INT   2fh
  2005.   OR    BX,BX
  2006.   JZ    @Finish
  2007.   MOV   AX,150Bh { check for using CD driver }
  2008.   MOV   CX,DriveNum
  2009.   INT   2fh
  2010.   OR    AX,AX
  2011.   @Finish:
  2012. end;
  2013.  
  2014. { This code is from the FileCtrl Unit; copyright Borland Intl 1995      }
  2015. { Check whether drive is a RAM drive.                                   }
  2016. function IsRAMDrive(DriveNum: Integer): Boolean; assembler;
  2017. var
  2018.   TempResult: Boolean;
  2019. asm
  2020.   MOV   TempResult,False
  2021.   PUSH  DS
  2022.   MOV   BX,SS
  2023.   MOV   DS,BX
  2024.   SUB   SP,0200h
  2025.   MOV   BX,SP
  2026.   MOV   AX,DriveNum
  2027.   MOV   CX,1
  2028.   XOR   DX,DX
  2029.   INT   25h  { read boot sector }
  2030.   ADD   SP,2
  2031.   JC    @ItsNot
  2032.   MOV   BX,SP
  2033.   CMP   BYTE PTR SS:[BX+15h],0F8h  { reverify fixed disk }
  2034.   JNE   @ItsNot
  2035.   CMP   BYTE PTR SS:[BX+10h],1  { check for single FAT }
  2036.   JNE   @ItsNot
  2037.   MOV   TempResult,True
  2038.   @ItsNot:
  2039.   ADD   SP,0200h
  2040.   POP   DS
  2041.   MOV   AL, TempResult
  2042. end;
  2043.  
  2044. { This code is from the FileCtrl Unit; copyright Borland Intl 1995      }
  2045. { Finds the type of a drive letter.                                     }
  2046. function FindDriveType(DriveNum: Integer): TDriveType;
  2047. begin
  2048.   Result := TDriveType(GetDriveType(DriveNum));
  2049.   if (Result = dtFixed) or (Result = dtNetwork) then
  2050.   begin
  2051.     if IsCDROM(DriveNum) then Result := dtCDROM
  2052.     else if (Result = dtFixed) then
  2053.     begin
  2054.         { do not check for RAMDrive under Windows NT }
  2055.       if ((GetWinFlags and $4000) = 0) and IsRAMDrive(DriveNum) then
  2056.         Result := dtRAM;
  2057.     end;
  2058.   end;
  2059. end;*)
  2060.  
  2061. begin
  2062.   { Set the button colors to an aquamarine color scheme for drives }
  2063.   ButtonColor := clTeal;
  2064.   ButtonHLColor := clAqua;
  2065.   ButtonSColor := clNavy;
  2066.   TextColor := clblack;
  2067.   { Set initial variables before looping for all drives }
  2068.   finished := false;
  2069.   DriveNum := 0;
  2070.   while not finished do
  2071.   begin
  2072.     { Start with no drive found }
  2073.     IconType := 0;
  2074.     (*=============REMOVED DUE TO WINDOWS 95=========
  2075.     { Call the Borland method to get the drive info }
  2076.     DriveType := FindDriveType(DriveNum);
  2077.     ===============END WINDOWS 95 REMOVAL==========*)
  2078.     { Set its letter and make it uppercase }
  2079.     DriveChar := Chr(DriveNum + ord('a'));
  2080.     DriveChar := Upcase(DriveChar);
  2081.     StrPCopy( DrivePC , DriveChar + ':\' );
  2082.     {*&&&&&&&&&&&&&&&  WIN 95 CALL  &&&&&&&&&&&&&&&&&&&*}
  2083.     DriveType := TDriveType(GetDriveType( DrivePC ));
  2084.     { Assign an icon based on the drive type; if no drive exists type is nil }
  2085.     case DriveType of
  2086.       dtFloppy  : IconType := 1;
  2087.       dtFixed   : IconType := 2;
  2088.       dtNetwork : IconType := 3;
  2089.       dtCDROM   : IconType := 4;
  2090.       dtRAM     : IconType := 5;
  2091.     end;
  2092.     { Set to check next drive letter }
  2093.     DriveNum := DriveNum + 1;
  2094.     { But if no match then out of drives so set exit flag }
  2095.     if IconType = 0 then finished := true;
  2096.     { If drive was valid then set up the new FileIconPanel on the imported }
  2097.     { Scrollbox                                                            }
  2098.     if not finished then
  2099.     begin
  2100.       { Create the FileIconPanel and set its parent for memory mgmt and display}
  2101.       TheFIP := TFileIconPanel.Create( Self );
  2102.       TheFIP.Parent := Self;
  2103.       { Call its initialize method with imported position values and the   }
  2104.       { preset color scheme, a drive caption, and a minimum font. Note the }
  2105.       { setting of the ExtraData field to non-zero; this signals a drive   }
  2106.       { rather than a file being sent in.                                  }
  2107.       TheFIP.Initialize((( XCounter - 1 ) * TheIconSpacing ),
  2108.        (( YCounter - 1  ) * TheIconSpacing ) , TheIconSize , TheIconSize , 3 ,
  2109.         7 , ButtonColor, ButtonHLColor,
  2110.        ButtonSColor , TextColor , 'DRIVE ' + DriveChar + ':' , 'MS Serif' , [] ,
  2111.        IconType );
  2112.       { Increment the column counter; if it exceeds max move to new row      }
  2113.       { Note that these are 'var' parameters and will export final position. }
  2114.       XCounter := XCounter + 1;
  2115.       if XCounter > MaxIconsInARow then
  2116.       begin
  2117.         XCounter := 1;
  2118.         YCounter := YCounter + 1;
  2119.       end;
  2120.     end;
  2121.   end;
  2122. end;
  2123.  
  2124. { This procedure assigns colors to FIP's based on file attributes }
  2125. procedure TFileIconPanelScrollBox.GetColorsForFileIcon( TheFile : String;
  2126.            var BC , HC , SC , TC : TColor );
  2127. var AmADir      ,             { Booleans hold file attribs }
  2128.     AmAnArchive ,
  2129.     AmAVolumeId ,
  2130.     AmHidden    ,
  2131.     AmReadOnly  ,
  2132.     AmSystem      : Boolean;
  2133. begin
  2134.   { Make the call to internal fileworkbench to set attributes }
  2135.   TheFWB.GetFileAttributes( TheFile , AmADir , AmAnArchive , AmAVolumeId ,
  2136.    AmHidden , AmReadOnly , AmSystem );
  2137.   { Volume ID has no subtypes }
  2138.   if AmAVolumeID then
  2139.   begin
  2140.     BC := clOlive;
  2141.     HC := clYellow;
  2142.     SC := clBlack;
  2143.     TC := clWhite;
  2144.     exit;
  2145.   end;
  2146.   { Check all directory combinations }
  2147.   if AmADir then
  2148.   begin
  2149.     BC := clNavy;
  2150.     HC := clBlue;
  2151.     SC := clBlack;
  2152.     TC := clWhite;
  2153.     if AmHidden then
  2154.     begin
  2155.       if AmReadOnly then
  2156.       begin
  2157.         if AmSystem then
  2158.         begin { One HECK of a file! }
  2159.           BC := clBlack;
  2160.           HC := clSilver;
  2161.           SC := clGray;
  2162.           TC := clWhite;
  2163.         end
  2164.         else
  2165.         begin { Dir,RO,Hid }
  2166.           BC := clMaroon;
  2167.           HC := clFuchsia;
  2168.           SC := clGreen;
  2169.           TC := clWhite;
  2170.         end;
  2171.       end
  2172.       else
  2173.       begin { Dir,Hid }
  2174.         BC := clPurple;
  2175.         HC := clFuchsia;
  2176.         SC := clBlack;
  2177.         TC := clWhite;
  2178.       end;
  2179.     end
  2180.     else
  2181.     begin
  2182.       if AmReadOnly then
  2183.       begin
  2184.         if AmSystem then
  2185.         begin { Dir,RO,Sys }
  2186.           BC := clMaroon;
  2187.           HC := clLime;
  2188.           SC := clGreen;
  2189.           TC := clWhite;
  2190.         end
  2191.         else
  2192.         begin { Dir,RO }
  2193.           BC := clGreen;
  2194.           HC := clLime;
  2195.           SC := clBlack;
  2196.           TC := clWhite;
  2197.         end;
  2198.       end
  2199.       else
  2200.       begin
  2201.         if AmSystem then
  2202.         begin { Dir,Sys }
  2203.           BC := clMaroon;
  2204.           HC := clRed;
  2205.           SC := clBlack;
  2206.           TC := clWhite;
  2207.         end;
  2208.       end;
  2209.     end;
  2210.   end
  2211.   else { Archive Only; check all combinations }
  2212.   begin
  2213.     BC := clSilver;
  2214.     HC := clWhite;
  2215.     SC := clGray;
  2216.     TC := clBlack;
  2217.     if AmHidden then
  2218.     begin
  2219.       if AmReadOnly then
  2220.       begin
  2221.         if AmSystem then
  2222.         begin { Hid,RO,Sys }
  2223.           BC := clRed;
  2224.           HC := clLime;
  2225.           SC := clPurple;
  2226.           TC := clBlack;
  2227.         end
  2228.         else
  2229.         begin { RO,Hid }
  2230.           BC := clLime;
  2231.           HC := clFuchsia;
  2232.           SC := clMaroon;
  2233.           TC := clBlack;
  2234.         end;
  2235.       end
  2236.       else
  2237.       begin { Hid }
  2238.         BC := clFuchsia;
  2239.         HC := clWhite;
  2240.         SC := clPurple;
  2241.         TC := clBlack;
  2242.       end;
  2243.     end
  2244.     else
  2245.     begin
  2246.       if AmReadOnly then
  2247.       begin
  2248.         if AmSystem then
  2249.         begin { RO,Sys }
  2250.           BC := clRed;
  2251.           HC := clLime;
  2252.           SC := clMaroon;
  2253.           TC := clBlack;
  2254.         end
  2255.         else
  2256.         begin { RO }
  2257.           BC := clLime;
  2258.           HC := clWhite;
  2259.           SC := clGreen;
  2260.           TC := clBlack;
  2261.         end;
  2262.       end
  2263.       else
  2264.       begin
  2265.         if AmSystem then
  2266.         begin { System }
  2267.           BC := clRed;
  2268.           HC := clWhite;
  2269.           SC := clMaroon;
  2270.           TC := clBlack;
  2271.         end;
  2272.       end;
  2273.     end;
  2274.   end;
  2275. end;
  2276.  
  2277. { This procedure gets all icons for an given directory, including drives and }
  2278. { standard subdirectories. It does not get special combinations or h/ro/sys  }
  2279. procedure TFileIconPanelScrollbox.GetIconsForEntireDirectory(
  2280.             TargetPath  : String );
  2281. var Finished        : Boolean;         { Loop flag              }
  2282.     TheSR           : TSearchRec;      { Searchrecord for FF/FN }
  2283.     TheResult       : Integer;         { return variable        }
  2284.     TempPath        : String;          { path for FF/FN         }
  2285.     TheFIP          : TFileIconPanel;  { generic FIP holder     }
  2286.     RowCounter    ,                    { position in row of FIP }
  2287.     ColumnCounter   : Integer;         { position in col of FIP }
  2288.     ButtonColor   ,                    { main panel color       }
  2289.     ButtonHLColor ,                    { bright panel color     }
  2290.     ButtonSColor  ,                    { dark panel color       }
  2291.     Textcolor       : TColor;          { label text color       }
  2292.     IsADir ,                           { Variable for file attr }
  2293.     IsAnArchive ,
  2294.     IsAVolumeID,
  2295.     IsAReadOnlyFile,
  2296.     IsAHiddenFile ,
  2297.     IsASystemFile     : Boolean;
  2298.     MaxTextLength     : Integer;       { Used to safely set size}
  2299. begin
  2300.   { hide during refresh }
  2301.   Visible := false;
  2302.   { Get the icon sizes }
  2303.   TheFIP := TFileIconPanel.Create( Self );
  2304.   TheFIP.Parent := Self;
  2305.   TheFIP.FTheLabel.Canvas.Font.Name := 'MS Serif';
  2306.   TheFIP.FTheLabel.Canvas.Font.Size := 7;
  2307.   MaxTextLength := TheFIP.FTheLabel.Canvas.TextWidth( 'COMMAND.COM' );
  2308.   TheFIP.Free;
  2309.   TheIconSize := MaxTextLength + 13;
  2310.   TheIconSpacing := TheIconSize + 5;
  2311.   { Set up maximum icons per row based on screen size }
  2312.   MaxIconsInARow := ( Screen.Width div TheIconSpacing );
  2313.   { Set up the position counters }
  2314.   RowCounter := 1;
  2315.   ColumnCounter := 1;
  2316.   { Get the drives for the current machine }
  2317.   AddDriveIcons( ColumnCounter , RowCounter  );
  2318.   { Set up the initial variables }
  2319.   Finished := false;
  2320.   TempPath := TargetPath + '*.*';
  2321.   { Make the call to FindFirst set to get any file; will return '.' }
  2322.   { so discard it.                                                  }
  2323.   TheResult := FindFirst( TempPath , faAnyFile , TheSR );
  2324.   { loop through all files in the directory and look for directories }
  2325.   while not Finished do
  2326.   begin
  2327.     { Make call to FindNext, using only SearchRecord from FindFirst }
  2328.     TheResult := FindNext( TheSR );
  2329.     { A -1 result means no more files so exit }
  2330.     if TheResult <> 0 then finished := true else
  2331.     begin
  2332.       { Otherwise check for a directory attribute }
  2333.       if (( FileGetAttr( TargetPath + TheSR.Name ) and faDirectory ) =
  2334.        faDirectory ) then
  2335.       begin
  2336.         GetColorsForFileIcon( TargetPath + TheSR.Name , ButtonColor ,
  2337.          ButtonHLColor , ButtonSColor , TextColor );
  2338.         { If found create a new FileIconPanel on the imported scrollbox }
  2339.         { Note sending 0 ExtraData parameter to indicate file not drive }
  2340.         TheFIP := TFileIconPanel.Create( Self );
  2341.         TheFIP.Parent := Self;
  2342.         TheFIP.Initialize((( ColumnCounter - 1 ) * TheIconSpacing ),
  2343.          (( RowCounter - 1  ) * TheIconSpacing ) , TheIconSize, TheIconSize ,
  2344.           3 , 7 , ButtonColor, ButtonHLColor , ButtonSColor , TextColor ,
  2345.            TargetPath + TheSr.Name , 'MS Serif' , [] , 0 );
  2346.         { Increment column counter and move to new row if past limit }
  2347.         ColumnCounter := ColumnCounter + 1;
  2348.         if ColumnCounter > MaxIconsInARow then
  2349.         begin
  2350.           ColumnCounter := 1;
  2351.           RowCounter := RowCounter + 1;
  2352.         end;
  2353.       end;
  2354.     end;
  2355.   end;
  2356.   { Set up new initialization variables }
  2357.   Finished := false;
  2358.   TempPath := TargetPath + '*.*';
  2359.   { Make needed call to FindFirst and discard '.' }
  2360.   TheResult := FindFirst( TempPath , faAnyFile , TheSR );
  2361.   while not Finished do
  2362.   begin
  2363.     { Loop through file again, this time getting only archive files }
  2364.     TheResult := FindNext( TheSR );
  2365.     { Result of -1 indicates no more files }
  2366.     if TheResult <> 0 then Finished := true else
  2367.     begin
  2368.       { If faArchive file then add new FileIconPanel }
  2369.       TheFWB.GetFileAttributes(( Targetpath + TheSR.Name ) , IsADir ,
  2370.        IsAnArchive , IsAVolumeId , IsAHiddenFile , IsAReadOnlyFile ,
  2371.         IsASystemFile );
  2372.       if (( IsAnArchive ) and ( not IsADir )) then
  2373.       begin
  2374.         GetColorsForFileIcon( TargetPath + TheSR.Name , ButtonColor ,
  2375.          ButtonHLColor , ButtonSColor , TextColor );
  2376.         { Initialize new FileIconPanel and call initialize, sending 0 ED }
  2377.         TheFIP := TFileIconPanel.Create( Self );
  2378.         TheFIP.Parent := Self;
  2379.         TheFIP.Initialize((( ColumnCounter - 1 ) * TheIconSpacing ),
  2380.          (( RowCounter - 1  ) * TheIconSpacing ) , TheIconSize , TheIconSize ,
  2381.           3 , 7 , ButtonColor, ButtonHLColor , ButtonSColor , TextColor ,
  2382.            TargetPath + TheSr.Name , 'MS Serif' , [] , 0 );
  2383.         { Increment column counter and if needed row counter }
  2384.         ColumnCounter := ColumnCounter + 1;
  2385.         if ColumnCounter > MaxIconsInARow then
  2386.         begin
  2387.           ColumnCounter := 1;
  2388.           RowCounter := RowCounter + 1;
  2389.         end;
  2390.       end;
  2391.     end;
  2392.   end;
  2393.   { Reset to visible }
  2394.   Visible := true;
  2395. end;
  2396.  
  2397. { Update method for FIPscrollbox }
  2398. procedure TFileIconPanelScrollBox.Update;
  2399. begin
  2400.   IconsNeedRefreshing := true;
  2401.   { Force a repaint }
  2402.   InvalidateRect( TheStoredHandle , nil , true );
  2403. end;
  2404.  
  2405. { Create method for FIPScrollbox }
  2406. constructor TFileIconPanelScrollBox.Create( AOwner : TComponent );
  2407. begin
  2408.   inherited Create( AOwner );
  2409.   TheFWB := TFileWorkBench.Create( Self );
  2410. end;
  2411.  
  2412. { This function returns the next selected file's name }
  2413. function TFileIconPanelScrollBox.GetNextSelection( SourceDirectory : String;
  2414.                            var CurrentItem : Integer ) : String;
  2415. var TheResult    : String;      { Holds result of function }
  2416.     TheComponent : TComponent;  { Used for typecast        }
  2417.     finished     : boolean;     { Loop control variable    }
  2418.     TheComponentCount : Integer;
  2419. begin
  2420.   TheComponentCount := ComponentCount;
  2421.   { If past end of components exit with no result }
  2422.   if CurrentItem > TheComponentCount then TheResult := '' else
  2423.   begin
  2424.     { Set loop counter and run till find match or run out }
  2425.     finished := false;
  2426.     while not finished do
  2427.     begin
  2428.       { Pull component out of the list and check it }
  2429.       TheComponent := Components[ CurrentItem - 1 ];
  2430.       { Increment counter for later }
  2431.       CurrentItem := CurrentItem + 1;
  2432.       { Do the typecast with AS }
  2433.       if TheComponent is TFileIconPanel then
  2434.       with TheComponent as TFileIconPanel do
  2435.       begin
  2436.         { If its selected make sure OK }
  2437.         if Selected then
  2438.         begin
  2439.           { Don't accept backup for this level of operation }
  2440.           if FTheLabel.Caption <> '..' then
  2441.           begin
  2442.             { Otherwise return the name and abort the loop }
  2443.             TheResult := FTheName;
  2444.             finished := true;
  2445.           end;
  2446.         end
  2447.         else
  2448.         begin
  2449.           { Check to see if out of components }
  2450.           if CurrentItem > TheComponentCount then
  2451.           begin
  2452.             { If so signal error and abort }
  2453.             TheResult := '';
  2454.             finished := true;
  2455.           end;
  2456.         end;
  2457.       end;
  2458.     end;
  2459.   end;
  2460.   GetNextSelection := TheResult;
  2461. end;
  2462.  
  2463. { This procedure places a selection of files in the display based on wildcards }
  2464. procedure TFileIconPanelScrollBox.DisplayRecursiveSearchResults(
  2465.            TheStartingDirectory : String );
  2466. var XCounter ,
  2467.     YCounter   : Integer;
  2468.  
  2469. { This procedure does a recursive file search by first getting all matches (in-}
  2470. { cluding directories) and adding them to the list. Then it checks for ALL the }
  2471. { subdirectories and does the same trick on them til there are no more matches }
  2472. { and no more subdirectories, at which point it exits and recurses back up.    }
  2473. procedure RecursiveFileSearch( TheWorkingDirectory : String; var XCounter ,
  2474.                                YCounter : Integer );
  2475.  
  2476. { VITAL!!! These variables MUST be local for recursrion to work! }
  2477. var
  2478.     Finished        : Boolean;         { Loop flag              }
  2479.     TheSR           : TSearchRec;      { Searchrecord for FF/FN }
  2480.     TheResult       : Integer;         { return variable        }
  2481.     TargetPath ,
  2482.     FileMask   ,
  2483.     TheStoredWorkingDirectory ,
  2484.     ModifiedDirectory  : String;       { path for FF/FN         }
  2485.     TheFIP          : TFileIconPanel;  { generic FIP holder     }
  2486.     ButtonColor   ,                    { main panel color       }
  2487.     ButtonHLColor ,                    { bright panel color     }
  2488.     ButtonSColor  ,                    { dark panel color       }
  2489.     Textcolor       : TColor;          { label text color       }
  2490.  
  2491. begin
  2492.   { Jump out if abort pressed }
  2493.   if GlobalAbortFlag then exit;
  2494.   { Set up the initial variables }
  2495.   Finished := false;
  2496.   TheStoredWorkingDirectory := TheWorkingDirectory;
  2497.   Targetpath := ExtractFilePath( TheWorkingDirectory );
  2498.   FileMask := ExtractFileName( TheWorkingDirectory );
  2499.   { Make the call to FindFirst set to get any file }
  2500.   TheResult := FindFirst( TheWorkingDirectory , faAnyFile , TheSR );
  2501.   if TheResult < 0 then finished := true;
  2502.   if (( TheSr.Name <> '.' ) and ( TheSr.Name <> '..' ) and ( TheResult >= 0 ))
  2503.   then begin
  2504.     if (( FileGetAttr( TargetPath + TheSR.Name ) and faDirectory ) =
  2505.      faDirectory ) then
  2506.     begin { A directory }
  2507.       GetColorsForFileIcon( TargetPath + TheSR.Name , ButtonColor ,
  2508.        ButtonHLColor , ButtonSColor , TextColor );
  2509.       { If found create a new FileIconPanel on the imported scrollbox }
  2510.       { Note sending 0 ExtraData parameter to indicate file not drive }
  2511.       TheFIP := TFileIconPanel.Create( Self );
  2512.       TheFIP.Parent := Self;
  2513.       TheFIP.Initialize((( XCounter - 1 ) * TheIconSpacing ),
  2514.        (( YCounter - 1  ) * TheIconSpacing ) , TheIconSize , TheIconSize , 3 ,
  2515.         7 , ButtonColor, ButtonHLColor , ButtonSColor , TextColor , TargetPath
  2516.          + TheSr.Name , 'MS Serif' , [] , 0 );
  2517.       { Increment column counter and move to new row if past limit }
  2518.       XCounter := XCounter + 1;
  2519.       if XCounter > MaxIconsInARow then
  2520.       begin
  2521.         XCounter := 1;
  2522.         YCounter := YCounter + 1;
  2523.       end;
  2524.     end
  2525.     else
  2526.     begin { A File }
  2527.       { Set up the default color scheme for files }
  2528.       GetColorsForFileIcon( TargetPath + TheSR.Name , ButtonColor ,
  2529.        ButtonHLColor , ButtonSColor , TextColor );
  2530.       { If found create a new FileIconPanel on the imported scrollbox }
  2531.       { Note sending 0 ExtraData parameter to indicate file not drive }
  2532.       TheFIP := TFileIconPanel.Create( Self );
  2533.       TheFIP.Parent := Self;
  2534.       TheFIP.Initialize((( XCounter - 1 ) * TheIconSpacing ),
  2535.        (( YCounter - 1  ) * TheIconSpacing ) , TheIconSize, TheIconSize , 3 ,
  2536.         7 , ButtonColor, ButtonHLColor , ButtonSColor , TextColor , TargetPath
  2537.          + TheSr.Name , 'MS Serif' , [] , 0 );
  2538.       { Increment column counter and move to new row if past limit }
  2539.       XCounter := XCounter + 1;
  2540.       if XCounter > MaxIconsInARow then
  2541.       begin
  2542.         XCounter := 1;
  2543.         YCounter := YCounter + 1;
  2544.       end;
  2545.     end;
  2546.   end;
  2547.   { loop through all files in the directory and look for matches }
  2548.   while not Finished do
  2549.   begin
  2550.     { Allow keyboard processing and jump out if c-break hit }
  2551.     Application.ProcessMessages;
  2552.     if GlobalAbortFlag then exit;
  2553.     { Make call to FindNext, using only SearchRecord from FindFirst }
  2554.     TheResult := FindNext( TheSR );
  2555.     { A -1 result means no more files so exit }
  2556.     if TheResult <> 0 then finished := true else
  2557.     begin
  2558.       if (( FileGetAttr( TargetPath + TheSR.Name ) and faDirectory ) =
  2559.        faDirectory ) then
  2560.       begin { A directory }
  2561.         { Set up the blue color scheme for directories }
  2562.         GetColorsForFileIcon( TargetPath + TheSR.Name , ButtonColor ,
  2563.          ButtonHLColor , ButtonSColor , TextColor );
  2564.         { If found create a new FileIconPanel on the imported scrollbox }
  2565.         { Note sending 0 ExtraData parameter to indicate file not drive }
  2566.         TheFIP := TFileIconPanel.Create( Self );
  2567.         TheFIP.Parent := Self;
  2568.         TheFIP.Initialize((( XCounter - 1 ) * TheIconSpacing ),
  2569.          (( YCounter - 1  ) * TheIconSpacing ) , TheIconSize , TheIconSize , 3 ,
  2570.            7 , ButtonColor, ButtonHLColor , ButtonSColor , TextColor ,
  2571.             TargetPath + TheSr.Name , 'MS Serif' , [] , 0 );
  2572.         { Increment column counter and move to new row if past limit }
  2573.         XCounter := XCounter + 1;
  2574.         if XCounter > MaxIconsInARow then
  2575.         begin
  2576.           XCounter := 1;
  2577.           YCounter := YCounter + 1;
  2578.         end;
  2579.       end
  2580.       else
  2581.       begin { A File }
  2582.         { Set up the default color scheme for files }
  2583.         GetColorsForFileIcon( TargetPath + TheSR.Name , ButtonColor ,
  2584.          ButtonHLColor , ButtonSColor , TextColor );
  2585.         { If found create a new FileIconPanel on the imported scrollbox }
  2586.         { Note sending 0 ExtraData parameter to indicate file not drive }
  2587.         TheFIP := TFileIconPanel.Create( Self );
  2588.         TheFIP.Parent := Self;
  2589.         TheFIP.Initialize((( XCounter - 1 ) * TheIconSpacing ),
  2590.          (( YCounter - 1  ) * TheIconSpacing ) , TheIconSize , TheIconSize , 3 ,
  2591.           7 , ButtonColor, ButtonHLColor , ButtonSColor , TextColor ,
  2592.            TargetPath + TheSr.Name , 'MS Serif' , [] , 0 );
  2593.         { Increment column counter and move to new row if past limit }
  2594.         XCounter := XCounter + 1;
  2595.         if XCounter > MaxIconsInARow then
  2596.         begin
  2597.           XCounter := 1;
  2598.           YCounter := YCounter + 1;
  2599.         end;
  2600.       end;
  2601.     end;
  2602.   end;
  2603.   { Set up the variables to do recursive calls on all directories}
  2604.   Finished := false;
  2605.   ModifiedDirectory := ExtractFilePath( TheWorkingdirectory ) + '*.*';
  2606.   { Make the call to FindFirst set to get any file, ignore result }
  2607.   TheResult := FindFirst( ModifiedDirectory , faDirectory , TheSR );
  2608.   while not Finished do
  2609.   begin
  2610.     { Allow keyboard input and jump out if c-break hit }
  2611.     Application.ProcessMessages;
  2612.     if GlobalAbortFlag then exit;
  2613.     { Make call to FindNext, using only SearchRecord from FindFirst }
  2614.     TheResult := FindNext( TheSR );
  2615.     { A -1 result means no more files so exit }
  2616.     if TheResult <> 0 then finished := true
  2617.     else
  2618.     begin
  2619.       if TheSR.Name <> '..' then { Ignore backup in this case }
  2620.       begin
  2621.         { Do second check due to bug in FindNext }
  2622.         if (( FileGetAttr( TargetPath + TheSR.Name ) and faDirectory )
  2623.         = faDirectory ) then
  2624.         begin
  2625.           { Set up modified directory to recurse into }
  2626.           ModifiedDirectory := ExtractFilePath( TheStoredWorkingDirectory ) +
  2627.            TheSR.Name + '\' + FileMask;
  2628.           { Perform the recursion }
  2629.           RecursiveFileSearch( ModifiedDirectory , XCounter , YCounter );
  2630.         end;
  2631.       end;
  2632.     end;
  2633.   end;
  2634. end;
  2635.  
  2636. begin
  2637.   { Keep the scrollbox from updating during refresh }
  2638.   Visible := false;
  2639.   { Make the clear call }
  2640.   ClearTheFIPs;
  2641.   XCounter := 1;
  2642.   YCounter := 1;
  2643.   { Get the drives for the current machine }
  2644.   AddDriveIcons( XCounter , YCounter );
  2645.   { Clear the global abort flag prior to processing }
  2646.   GlobalAbortFlag := false;
  2647.   RecursiveFileSearch( TheStartingDirectory , XCounter , YCounter );
  2648.   { Make the scrollbox visible again }
  2649.   Visible := true;
  2650. end;
  2651.  
  2652. end.
  2653.