home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1997 May / Pcwk0597.iso / borland / cb / setup / cbuilder / data.z / FILECTRL.INT < prev    next >
Text File  |  1997-02-28  |  9KB  |  303 lines

  1.  
  2. {*******************************************************}
  3. {                                                       }
  4. {       Delphi Visual Component Library                 }
  5. {                                                       }
  6. {       Copyright (c) 1995-1997 Borland International   }
  7. {                                                       }
  8. {*******************************************************}
  9.  
  10. unit FileCtrl;        // $Revision:   1.12  $
  11.  
  12. {$R-}
  13.  
  14. interface
  15.  
  16. uses Windows, Messages, SysUtils, Classes, Controls, Graphics, Forms,
  17.   Menus, StdCtrls, Buttons;
  18.  
  19. type
  20.   TFileAttr = (ftReadOnly, ftHidden, ftSystem, ftVolumeID, ftDirectory,
  21.     ftArchive, ftNormal);
  22.   TFileType = set of TFileAttr;
  23.  
  24.   TDriveType = (dtUnknown, dtNoDrive, dtFloppy, dtFixed, dtNetwork, dtCDROM,
  25.     dtRAM);
  26.  
  27.   TDirectoryListBox = class;
  28.   TFilterComboBox = class;
  29.   TDriveComboBox = class;
  30.  
  31. { TFileListBox }
  32.  
  33.   TFileListBox = class(TCustomListBox)
  34.   protected
  35.     FDirectory: string;
  36.     FMask: string;
  37.     FFileType: TFileType;
  38.     FFileEdit: TEdit;
  39.     FDirList: TDirectoryListBox;
  40.     FFilterCombo: TFilterComboBox;
  41.     ExeBMP, DirBMP, UnknownBMP: TBitmap;
  42.     FOnChange: TNotifyEvent;
  43.     FLastSel: Integer;
  44.     FShowGlyphs: Boolean;
  45.     procedure CreateWnd; override;
  46.     procedure ReadBitmaps; virtual;
  47.     procedure Click; override;
  48.     procedure Change; virtual;
  49.     procedure ReadFileNames; virtual;
  50.     procedure DrawItem(Index: Integer; Rect: TRect; State: TOwnerDrawState);  override;
  51.     procedure Notification(AComponent: TComponent; Operation: TOperation); override;
  52.     function GetFilePath: string; virtual;
  53.   public
  54.     constructor Create(AOwner: TComponent); override;
  55.     destructor Destroy; override;
  56.     procedure Update;
  57.     procedure ApplyFilePath (const EditText: string); virtual;
  58.     property Drive: char;
  59.     property Directory: string;
  60.     property FileName: string;
  61.   published
  62.     property Align;
  63.     property Color;
  64.     property Ctl3D;
  65.     property DragCursor;
  66.     property DragMode;
  67.     property Enabled;
  68.     property ExtendedSelect;
  69.     property FileEdit: TEdit;
  70.     property FileType: TFileType default [ftNormal];
  71.     property Font;
  72.     property ImeMode;
  73.     property ImeName;
  74.     property IntegralHeight;
  75.     property ItemHeight;
  76.     property Mask: string;
  77.     property MultiSelect;
  78.     property ParentColor;
  79.     property ParentCtl3D;
  80.     property ParentFont;
  81.     property ParentShowHint;
  82.     property PopupMenu;
  83.     property ShowGlyphs: Boolean default False;
  84.     property ShowHint;
  85.     property TabOrder;
  86.     property TabStop;
  87.     property Visible;
  88.     property OnChange: TNotifyEvent;
  89.     property OnClick;
  90.     property OnDblClick;
  91.     property OnDragDrop;
  92.     property OnDragOver;
  93.     property OnEndDrag;
  94.     property OnEnter;
  95.     property OnExit;
  96.     property OnKeyDown;
  97.     property OnKeyPress;
  98.     property OnKeyUp;
  99.     property OnMouseDown;
  100.     property OnMouseMove;
  101.     property OnMouseUp;
  102.     property OnStartDrag;
  103.   end;
  104.  
  105. { TDirectoryListBox }
  106.  
  107.   TFolderBitmap = class(TBitmap)
  108.   public
  109.     constructor Create;
  110.   end;
  111.  
  112.   TDirectoryListBox = class(TCustomListBox)
  113.   protected
  114.     ClosedBMP, OpenedBMP, CurrentBMP: TFolderBitmap;
  115.     FDirectory: string;
  116.     FOnChange: TNotifyEvent;
  117.     procedure Change; virtual;
  118.     procedure DblClick; override;
  119.     procedure ReadBitmaps; virtual;
  120.     procedure CreateWnd; override;
  121.     procedure DrawItem(Index: Integer; Rect: TRect; State: TOwnerDrawState); override;
  122.     function  ReadDirectoryNames(const ParentDirectory: string;
  123.       DirectoryList: TStringList): Integer;
  124.     procedure BuildList; virtual;
  125.     procedure KeyPress(var Key: Char); override;
  126.     procedure Notification(AComponent: TComponent; Operation: TOperation); override;
  127.   public
  128.     constructor Create(AOwner: TComponent); override;
  129.     destructor Destroy; override;
  130.     function  DisplayCase(const S: String): String;
  131.     function  FileCompareText(const A, B: String): Integer;
  132.     function GetItemPath(Index: Integer): string;
  133.     procedure OpenCurrent;
  134.     procedure Update;
  135.     property Drive: Char;
  136.     property Directory: string;
  137.     property PreserveCase: Boolean;
  138.     property CaseSensitive: Boolean;
  139.   published
  140.     property Align;
  141.     property Color;
  142.     property Columns;
  143.     property Ctl3D;
  144.     property DirLabel: TLabel;
  145.     property DragCursor;
  146.     property DragMode;
  147.     property Enabled;
  148.     property FileList: TFileListBox;
  149.     property Font;
  150.     property ImeMode;
  151.     property ImeName;
  152.     property IntegralHeight;
  153.     property ItemHeight;
  154.     property ParentColor;
  155.     property ParentCtl3D;
  156.     property ParentFont;
  157.     property ParentShowHint;
  158.     property PopupMenu;
  159.     property ShowHint;
  160.     property TabOrder;
  161.     property TabStop;
  162.     property Visible;
  163.     property OnChange: TNotifyEvent;
  164.     property OnClick;
  165.     property OnDblClick;
  166.     property OnDragDrop;
  167.     property OnDragOver;
  168.     property OnEndDrag;
  169.     property OnEnter;
  170.     property OnExit;
  171.     property OnKeyDown;
  172.     property OnKeyPress;
  173.     property OnKeyUp;
  174.     property OnMouseDown;
  175.     property OnMouseMove;
  176.     property OnMouseUp;
  177.     property OnStartDrag;
  178.   end;
  179.  
  180. { TDriveComboBox }
  181.  
  182.   TTextCase = (tcLowerCase, tcUpperCase);
  183.  
  184.   TDriveComboBox = class(TCustomComboBox)
  185.   protected
  186.     FloppyBMP, FixedBMP, NetworkBMP, CDROMBMP, RAMBMP: TBitmap;
  187.     FOnChange: TNotifyEvent;
  188.     procedure CreateWnd; override;
  189.     procedure DrawItem(Index: Integer; Rect: TRect; State: TOwnerDrawState); override;
  190.     procedure Click; override;
  191.     procedure BuildList; virtual;
  192.     procedure Notification(AComponent: TComponent; Operation: TOperation); override;
  193.     procedure Change; dynamic;
  194.   public
  195.     constructor Create(AOwner: TComponent); override;
  196.     destructor Destroy; override;
  197.     property Text;
  198.     property Drive: Char;
  199.   published
  200.     property Color;
  201.     property Ctl3D;
  202.     property DirList: TDirectoryListBox;
  203.     property DragMode;
  204.     property DragCursor;
  205.     property Enabled;
  206.     property Font;
  207.     property ImeMode;
  208.     property ImeName;
  209.     property ParentColor;
  210.     property ParentCtl3D;
  211.     property ParentFont;
  212.     property ParentShowHint;
  213.     property PopupMenu;
  214.     property ShowHint;
  215.     property TabOrder;
  216.     property TabStop;
  217.     property TextCase: TTextCase default tcLowerCase;
  218.     property Visible;
  219.     property OnChange: TNotifyEvent;
  220.     property OnClick;
  221.     property OnDblClick;
  222.     property OnDragDrop;
  223.     property OnDragOver;
  224.     property OnDropDown;
  225.     property OnEndDrag;
  226.     property OnEnter;
  227.     property OnExit;
  228.     property OnKeyDown;
  229.     property OnKeyPress;
  230.     property OnKeyUp;
  231.     property OnStartDrag;
  232.   end;
  233.  
  234. { TFilterComboBox }
  235.  
  236.   TFilterComboBox = class(TCustomComboBox)
  237.   protected
  238.     FOnChange: TNotifyEvent;
  239.     procedure CreateWnd; override;
  240.     procedure Click; override;
  241.     procedure BuildList;
  242.     procedure Notification(AComponent: TComponent; Operation: TOperation); override;
  243.     procedure Change; dynamic;
  244.   public
  245.     constructor Create(AOwner: TComponent); override;
  246.     destructor Destroy; override;
  247.     property Mask: string;
  248.     property Text;
  249.   published
  250.     property Color;
  251.     property Ctl3D;
  252.     property DragMode;
  253.     property DragCursor;
  254.     property Enabled;
  255.     property FileList: TFileListBox;
  256.     property Filter: string;
  257.     property Font;
  258.     property ImeMode;
  259.     property ImeName;
  260.     property ParentColor;
  261.     property ParentCtl3D;
  262.     property ParentFont;
  263.     property ParentShowHint;
  264.     property PopupMenu;
  265.     property ShowHint;
  266.     property TabOrder;
  267.     property TabStop;
  268.     property Visible;
  269.     property OnChange: TNotifyEvent;
  270.     property OnClick;
  271.     property OnDblClick;
  272.     property OnDragDrop;
  273.     property OnDragOver;
  274.     property OnDropDown;
  275.     property OnEndDrag;
  276.     property OnEnter;
  277.     property OnExit;
  278.     property OnKeyDown;
  279.     property OnKeyPress;
  280.     property OnKeyUp;
  281.     property OnStartDrag;
  282.   end;
  283.  
  284. procedure ProcessPath (const EditText: string; var Drive: Char;
  285.   var DirPart: string; var FilePart: string);
  286.  
  287. function MinimizeName(const Filename: TFileName; Canvas: TCanvas;
  288.   MaxLen: Integer): TFileName;
  289.  
  290. const
  291.   WNTYPE_DRIVE = 1;  { from WINNET.H, WFW 3.1 SDK }
  292.  
  293. type
  294.   TSelectDirOpt = (sdAllowCreate, sdPerformCreate, sdPrompt);
  295.   TSelectDirOpts = set of TSelectDirOpt;
  296.  
  297. function SelectDirectory(var Directory: string;
  298.   Options: TSelectDirOpts; HelpCtx: Longint): Boolean;
  299. function DirectoryExists(const Name: string): Boolean;
  300. procedure ForceDirectories(Dir: string);
  301.  
  302. implementation
  303.