bsSkinShellCtrls.pas
上传用户:hylc_2004
上传日期:2014-01-23
资源大小:46800k
文件大小:106k
源码类别:
Delphi控件源码
开发平台:
Delphi
- {*******************************************************************}
- { }
- { Almediadev Visual Component Library }
- { BusinessSkinForm }
- { Version 1.98 }
- { }
- { Copyright (c) 2000-2003 Almediadev }
- { ALL RIGHTS RESERVED }
- { }
- { Home: http://www.almdev.com }
- { Support: support@almdev.com }
- { }
- {*******************************************************************}
- unit bsSkinShellCtrls;
- {$WARNINGS OFF}
- {$HINTS OFF}
- interface
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
- Dialogs, StdCtrls, ExtCtrls, ComCtrls, CommCtrl, ShellAPI, ShlObj,
- Menus, ImgList, bsSkinCtrls, BusinessSkinForm, bsSkinData, bsSkinBoxCtrls,
- bsFileCtrl;
- type
- TDiskSign = String[2];
- TMediaType = (dtUnknown, dtNotExists, dtRemovable, dtFixed, dtRemote, dtCDROM, dtRAMDisk);
- TFileFlag = (fsCaseIsPreserved, fsCaseSensitive, fsUnicodeStoredOnDisk,
- fsPersistentAcls, fsFileCompression, fsVolumeIsCompressed,
- fsLongFileNames,
- fsEncryptedFileSystemSupport, fsObjectIDsSupport, fsReparsePointsSupport,
- fsSparseFilesSupport, fsDiskQuotasSupport);
- TFileFlags = set of TFileFlag;
- TDiskInfo = record
- Sign: TDiskSign;
- MediaType: TMediaType;
- FileFlags: TFileFlags;
- SectorsPerCluster,
- BytesPerSector,
- FreeClusters,
- TotalClusters,
- Serial: DWORD;
- Capacity,
- FreeSpace: Int64;
- VolumeLabel,
- SerialNumber,
- FileSystem: String;
- end;
- TObjectType = (otFile, otDirectory, otDisk);
- TObjectTypes = set of TObjectType;
- TFileAttr = (ftReadOnly, ftHidden, ftSystem, ftArchive, ftNormal);
- TFileType = Set of TFileAttr;
- TbsSkinFileListView = class(TbsSkinListView)
- private
- FDirectory: String;
- FDirectorySize: integer;
- FFileName: String;
- FFileType: TFileType;
- FMask: String;
- FContextMenu: Boolean;
- FSortColumn: integer;
- FSortForward: boolean;
- LImageList, SImageList: TImageList;
- FContextAction: Boolean;
- FSelectedFiles :tStringlist;
- function GetSelectedNum: Integer;
- function GetSelectedSize: Integer;
- procedure Createimages;
- procedure CompareFiles(Sender: TObject; Item1,Item2: TListItem; Data: Integer; var Compare: Integer);
- procedure ColumnClick(Sender: TObject; Column: TListColumn);
- procedure WMRButtonDown(var Message: TWMRButtonDown); message WM_RBUTTONDOWN;
- procedure DoMouseDown(var Message: TWMMouse; Button: TMouseButton;
- Shift: TShiftState);
- function GetSelectedFilenames: String;
- function GetObjectTypes: TObjectTypes;
- function GetDiskCap: Int64;
- function GetDiskFree: Int64;
- protected
- function AddFile(FileMask: String; Attr: DWORD): Boolean;
- function GetFileName: String;
- function GetDirectory: String;
- procedure AddDrives;
- procedure Click; override;
- procedure DblClick; override;
- procedure Keydown(var Key: Word; Shift: TShiftState); override;
- procedure SetFileName(NewFile: String);
- procedure SetDirectory(NewDir: String);
- procedure SetFileType(NewFileType: TFileType);
- procedure SetMask(const NewMasks: String);
- function GetDiskInfo(Value: TDiskSign): TDiskInfo;
- public
- constructor Create(AOwner: TComponent); override;
- destructor Destroy; override;
- procedure CreateWnd; override;
- procedure OneLevelUp;
- procedure UpdateFileList;
- property FileName: String read GetFileName write SetFileName;
- property DiskCapacity: Int64 read GetDiskCap;
- property DiskFree: Int64 read GetDiskFree;
- function GetMediaTypeStr(MT: TMediaType): String;
- function IsFile(Item: TListItem): Boolean;
- published
- property HScrollBar;
- property VScrollBar;
- property SkinData;
- property SkinDataName;
- property Directory: String read GetDirectory write SetDirectory;
- property FileType: TFileType read FFileType write SetFileType;
- property Mask: String read FMask write SetMask;
- property ContextMenu: Boolean read FContextMenu write FContextMenu;
- property ContextAction: Boolean read FContextAction write FContextAction;
- property SelectedCount: Integer read GetSelectedNum;
- property SelectedSize: Integer read GetSelectedSize;
- property SelectedFilenames :String read GetSelectedFilenames;
- property SelectedTypes :TObjectTypes read GetObjectTypes;
- property Align;
- property BorderStyle;
- property Color;
- property DragCursor;
- property Font;
- property HideSelection;
- property IconOptions;
- property MultiSelect;
- property ParentShowHint;
- property ReadOnly;
- property RowSelect;
- property ShowColumnHeaders;
- property ShowHint;
- property TabOrder;
- property TabStop;
- property ViewStyle;
- property Visible;
- property OnChange;
- property OnChanging;
- property OnClick;
- property OnColumnClick;
- property OnCompare;
- property OnDblClick;
- property OnDeletion;
- property OnDragDrop;
- property OnDragOver;
- property OnEdited;
- property OnEditing;
- property OnEndDrag;
- property OnEnter;
- property OnExit;
- property OnInsert;
- property OnKeyDown;
- property OnKeyPress;
- property OnKeyUp;
- property OnMouseDown;
- property OnMouseMove;
- property OnMouseUp;
- property OnStartDrag;
- end;
- TDirChangeEvent = procedure(Sender: TObject; SelectedPath: string) of object;
- TbsSkinDirTreeView = class(TbsSkinCustomTreeView)
- private
- FPreviousPath: string;
- FSelectedPath: string;
- TreeViewPath: string;
- FIsNewFolder: Boolean;
- FInitialDir: String;
- FisCutCopy: Boolean;
- FOpMode: integer;
- FSrcPath: string;
- FDestPath: String;
- protected
- function GetDirectory: String;
- procedure SetDirectory(Value: String);
- procedure CreateWnd; override;
- procedure Expanding(Sender: TObject; Node: TTreeNode;
- var AllowExpansion: Boolean);
- procedure LoadRoot;
- procedure LoadDrives;
- procedure Loaded; override;
- procedure AddSubs(Path: string; Node: TTreeNode);
- procedure MakePath(Node: TTreeNode);
- procedure MouseDown(Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer); override;
- procedure KeyUp(var Key: Word; Shift: TShiftState); override;
- procedure SetInitialDir(Value: string);
- procedure SetSelectedPath(Value: string);
- function CanEdit(Node: TTreeNode): Boolean; override;
- procedure Edit(const Item: TTVItem); override;
- function GetPathFromNode(Node: TTreeNode): string;
- public
- constructor create(AOwner: TComponent); override;
- destructor destroy; override;
- property InitialDir: string read FInitialDir Write SetInitialDir;
- procedure ReLoad;
- procedure OpenPath(dPath: string);
- function AddNewNode(ParentNode: TTreeNode; NodeName: string):
- Boolean;
- function DeleteNode(Node: TTreeNode): Boolean;
- procedure CutOrCopyNode(Mode: integer);
- procedure PasteNode;
- property Images;
- property Items;
- property Directory: String read GetDirectory write SetDirectory;
- published
- property HScrollBar;
- property VScrollBar;
- property SkinData;
- property SkinDataName;
- property Align;
- property BorderStyle;
- property Color;
- property DragCursor;
- property Enabled;
- property Font;
- property Height;
- property HelpContext;
- property HideSelection;
- property Hint;
- property Indent;
- property Left;
- property Name;
- property ParentColor;
- property ParentFont;
- property ParentShowHint;
- property PopupMenu;
- property ReadOnly;
- property ShowButtons;
- property ShowHint;
- property ShowLines;
- property ShowRoot;
- property SortType;
- property TabOrder;
- property TabStop;
- property Tag;
- property Top;
- property Visible;
- property Width;
- property OnClick;
- property OnChange;
- property OnCollapsed;
- property OnCollapsing;
- property OnDblClick;
- property OnDeletion;
- property OnDragDrop;
- property OnDragOver;
- property OnEdited;
- property OnEditing;
- property OnEndDrag;
- property OnEnter;
- property OnExit;
- property OnExpanded;
- property OnExpanding;
- property OnKeyDown;
- property OnKeyPress;
- property OnKeyUp;
- property OnMouseDown;
- property OnMouseMove;
- property OnMouseUp;
- property OnStartDrag;
- property Anchors;
- property BiDiMode;
- property Constraints;
- end;
- TbsSkinShellDriveComboBox = class(TbsSkinComboBox)
- private
- Drives: TStrings;
- DriveItemIndex: Integer;
- Images: TImagelist;
- FDrive: Char;
- FOnChange: TNotifyEvent;
- protected
- procedure CreateWnd; override;
- procedure DrawItem(Cnvs: TCanvas; Index: Integer;
- ItemWidth, ItemHeight: Integer; TextRect: TRect; State: TOwnerDrawState);
- procedure BuildList; virtual;
- procedure SetDrive(Value: Char);
- public
- constructor Create(AOwner: TComponent); override;
- destructor Destroy; override;
- procedure UpdateDrives;
- procedure Change; override;
- published
- property Drive: Char read FDrive write SetDrive;
- property OnChange: TNotifyEvent read FOnChange write FOnChange;
- end;
- { Dialogs }
- TbsSelDirDlgForm = class(TForm)
- public
- BSF: TbsBusinessSkinForm;
- DirTreeViewPanel, BottomPanel: TbsSkinPanel;
- DirTreeView: TbsSkinDirTreeView;
- VScrollBar, HScrollBar: TbsSkinScrollBar;
- OkButton, CancelButton: TbsSkinButton;
- constructor Create(AOwner: TComponent); override;
- end;
- TbsSkinSelectDirectoryDialog = class(TComponent)
- private
- FSD: TbsSkinData;
- FCtrlFSD: TbsSkinData;
- FDefaultFont: TFont;
- FTitle: String;
- FDlgFrm: TbsSelDirDlgForm;
- FOnChange: TNotifyEvent;
- FDirectory: String;
- FAlphaBlend: Boolean;
- FAlphaBlendValue: Byte;
- FAlphaBlendAnimation: Boolean;
- function GetTitle: string;
- procedure SetTitle(const Value: string);
- procedure SetDefaultFont(Value: TFont);
- protected
- procedure Notification(AComponent: TComponent; Operation: TOperation); override;
- procedure Change;
- public
- DialogWidth, DialogHeight: Integer;
- constructor Create(AOwner: TComponent); override;
- destructor Destroy; override;
- function Execute: Boolean;
- published
- property AlphaBlend: Boolean read FAlphaBlend write FAlphaBlend;
- property AlphaBlendValue: Byte read FAlphaBlendValue write FAlphaBlendValue;
- property AlphaBlendAnimation: Boolean
- read FAlphaBlendAnimation write FAlphaBlendAnimation;
- property SkinData: TbsSkinData read FSD write FSD;
- property CtrlSkinData: TbsSkinData read FCtrlFSD write FCtrlFSD;
- property DefaultFont: TFont read FDefaultFont write SetDefaultFont;
- property Title: string read GetTitle write SetTitle;
- property Directory: String read FDirectory write FDirectory;
- end;
- TbsOpenDlgForm = class(TForm)
- private
- FromFLV: Boolean;
- FromFTV: Boolean;
- FromDCB: Boolean;
- SaveMode: Boolean;
- public
- FileName: String;
- BSF: TbsBusinessSkinForm;
- DirTreeViewPanel: TbsSkinExPanel;
- FileListViewPanel,
- BottomPanel: TbsSkinPanel;
- Splitter: TbsSkinSplitter;
- DTVHScrollBar, DTVVScrollBar,
- FLVHScrollBar, FLVVScrollBar: TbsSkinScrollBar;
- DirTreeView: TbsSkinDirTreeView;
- FileListView: TbsSkinFileListView;
- FileNameEdit: TbsSkinEdit;
- FilterComboBox: TbsSkinFilterComboBox;
- OpenButton, CancelButton: TbsSkinButton;
- OpenFileLabel, FileTypeLabel: TbsSkinStdLabel;
- ToolPanel: TbsSkinPanel;
- ListToolButton, ReportToolButton,
- IconToolButton, SmallIconToolButton, BackToolButton: TbsSkinSpeedButton;
- Bevel1, Bevel2, Bevel3: TbsSkinBevel;
- DriveBox: TbsSkinShellDriveComboBox;
- SortNameToolButton, SortSizeToolButton, SortDateToolButton: TbsSkinSpeedButton;
- constructor CreateEx(AOwner: TComponent; ASaveMode: Boolean);
- procedure FLVChange(Sender: TObject; Item: TListItem; Change: TItemChange);
- procedure DTVChange(Sender: TObject; Node: TTreeNode);
- procedure FCBChange(Sender: TObject);
- procedure DCBChange(Sender: TObject);
- procedure ToolPanelOnResize(Sender: TObject);
- procedure OpenButtonClick(Sender: TObject);
- procedure FLVDBLClick(Sender: TObject);
- procedure EditKeyPress(Sender: TObject; var Key: Char);
- procedure ReportToolButtonClick(Sender: TObject);
- procedure ListToolButtonClick(Sender: TObject);
- procedure SmallIconToolButtonClick(Sender: TObject);
- procedure IconToolButtonClick(Sender: TObject);
- procedure BackToolButtonClick(Sender: TObject);
- procedure SortNameToolButtonClick(Sender: TObject);
- procedure SortSizeToolButtonClick(Sender: TObject);
- procedure SortDateButtonClick(Sender: TObject);
- end;
- TbsSkinOpenDialog = class(TComponent)
- private
- FSD: TbsSkinData;
- FCtrlFSD: TbsSkinData;
- FLVHeaderSkinDataName: String;
- FDefaultFont: TFont;
- FTitle: String;
- FDlgFrm: TbsOpenDlgForm;
- FOnChange: TNotifyEvent;
- FInitialDir: String;
- FFilter: String;
- FFileName: String;
- FFilterIndex: Integer;
- FAlphaBlend: Boolean;
- FAlphaBlendValue: Byte;
- FAlphaBlendAnimation: Boolean;
- function GetTitle: string;
- procedure SetTitle(const Value: string);
- procedure SetDefaultFont(Value: TFont);
- protected
- FSaveMode: Boolean;
- procedure Notification(AComponent: TComponent; Operation: TOperation); override;
- procedure Change;
- public
- TreePanelWidth: Integer;
- TreePanelRollState: Boolean;
- ListViewStyle: TViewStyle;
- DialogWidth, DialogHeight: Integer;
- constructor Create(AOwner: TComponent); override;
- destructor Destroy; override;
- function Execute: Boolean;
- published
- property AlphaBlend: Boolean read FAlphaBlend write FAlphaBlend;
- property AlphaBlendValue: Byte read FAlphaBlendValue write FAlphaBlendValue;
- property AlphaBlendAnimation: Boolean
- read FAlphaBlendAnimation write FAlphaBlendAnimation;
- property LVHeaderSkinDataName: String
- read FLVHeaderSkinDataName write FLVHeaderSkinDataName;
- property SkinData: TbsSkinData read FSD write FSD;
- property CtrlSkinData: TbsSkinData read FCtrlFSD write FCtrlFSD;
- property DefaultFont: TFont read FDefaultFont write SetDefaultFont;
- property Title: string read GetTitle write SetTitle;
- property InitialDir: String read FInitialDir write FInitialDir;
- property Filter: String read FFilter write FFilter;
- property FilterIndex: Integer read FFilterIndex write FFilterIndex;
- property FileName: String read FFileName write FFileName;
- end;
- TbsSkinSaveDialog = class(TbsSkinOpenDialog)
- public
- constructor Create(AOwner: TComponent); override;
- end;
- TbsSkinDirectoryEdit = class(TbsSkinEdit)
- protected
- FDlgSkinData: TbsSkinData;
- FDlgCtrlSkinData: TbsSkinData;
- SD: TbsSkinSelectDirectoryDialog;
- procedure Notification(AComponent: TComponent; Operation: TOperation); override;
- public
- constructor Create(AOwner: TComponent); override;
- destructor Destroy; override;
- procedure ButtonClick(Sender: TObject);
- published
- property DlgSkinData: TbsSkinData read FDlgSkinData write FDlgSkinData;
- property DlgCtrlSkinData: TbsSkinData read FDlgCtrlSkinData write FDlgCtrlSkinData;
- end;
- TbsSkinFileEdit = class(TbsSkinEdit)
- protected
- FDlgSkinData: TbsSkinData;
- FDlgCtrlSkinData: TbsSkinData;
- OD: TbsSkinOpenDialog;
- FLVHeaderSkinDataName: String;
- function GetFilter: String;
- procedure SetFilter(Value: String);
- procedure Notification(AComponent: TComponent; Operation: TOperation); override;
- public
- constructor Create(AOwner: TComponent); override;
- destructor Destroy; override;
- procedure ButtonClick(Sender: TObject);
- published
- property Filter: String read GetFilter write SetFilter;
- property DlgSkinData: TbsSkinData read FDlgSkinData write FDlgSkinData;
- property DlgCtrlSkinData: TbsSkinData read FDlgCtrlSkinData write FDlgCtrlSkinData;
- property LVHeaderSkinDataName: String
- read FLVHeaderSkinDataName write FLVHeaderSkinDataName;
- end;
- TbsSkinSaveFileEdit = class(TbsSkinEdit)
- protected
- FDlgSkinData: TbsSkinData;
- FDlgCtrlSkinData: TbsSkinData;
- OD: TbsSkinSaveDialog;
- FLVHeaderSkinDataName: String;
- function GetFilter: String;
- procedure SetFilter(Value: String);
- procedure Notification(AComponent: TComponent; Operation: TOperation); override;
- public
- constructor Create(AOwner: TComponent); override;
- destructor Destroy; override;
- procedure ButtonClick(Sender: TObject);
- published
- property Filter: String read GetFilter write SetFilter;
- property DlgSkinData: TbsSkinData read FDlgSkinData write FDlgSkinData;
- property DlgCtrlSkinData: TbsSkinData read FDlgCtrlSkinData write FDlgCtrlSkinData;
- property LVHeaderSkinDataName: String
- read FLVHeaderSkinDataName write FLVHeaderSkinDataName;
- end;
- TbsOpenPictureDlgForm = class(TForm)
- private
- FromFLV: Boolean;
- FromFTV: Boolean;
- FromDCB: Boolean;
- SaveMode: Boolean;
- public
- FileName: String;
- BSF: TbsBusinessSkinForm;
- DirTreeViewPanel: TbsSkinExPanel;
- FileListViewPanel,
- BottomPanel: TbsSkinPanel;
- Splitter, Splitter2: TbsSkinSplitter;
- DTVHScrollBar, DTVVScrollBar,
- FLVHScrollBar, FLVVScrollBar: TbsSkinScrollBar;
- DirTreeView: TbsSkinDirTreeView;
- FileListView: TbsSkinFileListView;
- FileNameEdit: TbsSkinEdit;
- FilterComboBox: TbsSkinFilterComboBox;
- OpenButton, CancelButton: TbsSkinButton;
- OpenFileLabel, FileTypeLabel: TbsSkinStdLabel;
- ToolPanel: TbsSkinPanel;
- ListToolButton, ReportToolButton,
- IconToolButton, SmallIconToolButton, BackToolButton: TbsSkinSpeedButton;
- Bevel1, Bevel2, Bevel3: TbsSkinBevel;
- DriveBox: TbsSkinShellDriveComboBox;
- SortNameToolButton, SortSizeToolButton, SortDateToolButton: TbsSkinSpeedButton;
- //
- ImagePanel: TbsSkinPanel;
- Image: TImage;
- ScrollBox: TbsSkinScrollBox;
- SBVScrollBar, SBHScrollBar: TbsSkinScrollBar;
- Bevel4: TbsSkinBevel;
- StretchButton: TbsSkinSpeedButton;
- constructor CreateEx(AOwner: TComponent; ASaveMode: Boolean);
- procedure DCBChange(Sender: TObject);
- procedure FLVChange(Sender: TObject; Item: TListItem; Change: TItemChange);
- procedure DTVChange(Sender: TObject; Node: TTreeNode);
- procedure FCBChange(Sender: TObject);
- procedure OpenButtonClick(Sender: TObject);
- procedure ToolPanelOnResize(Sender: TObject);
- procedure FLVDBLClick(Sender: TObject);
- procedure EditKeyPress(Sender: TObject; var Key: Char);
- procedure StretchButtonClick(Sender: TObject);
- procedure ReportToolButtonClick(Sender: TObject);
- procedure ListToolButtonClick(Sender: TObject);
- procedure SmallIconToolButtonClick(Sender: TObject);
- procedure IconToolButtonClick(Sender: TObject);
- procedure BackToolButtonClick(Sender: TObject);
- procedure SortNameToolButtonClick(Sender: TObject);
- procedure SortSizeToolButtonClick(Sender: TObject);
- procedure SortDateButtonClick(Sender: TObject);
- end;
- TbsSkinOpenPictureDialog = class(TComponent)
- private
- FLVHeaderSkinDataName: String;
- FAlphaBlend: Boolean;
- FAlphaBlendValue: Byte;
- FAlphaBlendAnimation: Boolean;
- FSD: TbsSkinData;
- FCtrlFSD: TbsSkinData;
- FDefaultFont: TFont;
- FTitle: String;
- FDlgFrm: TbsOpenPictureDlgForm;
- FOnChange: TNotifyEvent;
- FInitialDir: String;
- FFilter: String;
- FFileName: String;
- FFilterIndex: Integer;
- function GetTitle: string;
- procedure SetTitle(const Value: string);
- procedure SetDefaultFont(Value: TFont);
- protected
- FSaveMode: Boolean;
- procedure Notification(AComponent: TComponent; Operation: TOperation); override;
- procedure Change;
- public
- ImagePanelWidth, TreePanelWidth: Integer;
- TreePanelRollState: Boolean;
- ListViewStyle: TViewStyle;
- DialogWidth, DialogHeight: Integer;
- DialogStretch: Boolean;
- constructor Create(AOwner: TComponent); override;
- destructor Destroy; override;
- function Execute: Boolean;
- published
- property LVHeaderSkinDataName: String
- read FLVHeaderSkinDataName write FLVHeaderSkinDataName;
- property AlphaBlend: Boolean read FAlphaBlend write FAlphaBlend;
- property AlphaBlendValue: Byte read FAlphaBlendValue write FAlphaBlendValue;
- property AlphaBlendAnimation: Boolean
- read FAlphaBlendAnimation write FAlphaBlendAnimation;
- property SkinData: TbsSkinData read FSD write FSD;
- property CtrlSkinData: TbsSkinData read FCtrlFSD write FCtrlFSD;
- property DefaultFont: TFont read FDefaultFont write SetDefaultFont;
- property Title: string read GetTitle write SetTitle;
- property InitialDir: String read FInitialDir write FInitialDir;
- property Filter: String read FFilter write FFilter;
- property FilterIndex: Integer read FFilterIndex write FFilterIndex;
- property FileName: String read FFileName write FFileName;
- end;
- TbsSkinSavePictureDialog = class(TbsSkinOpenPictureDialog)
- public
- constructor Create(AOwner: TComponent); override;
- end;
- implementation
- {$R bsSkinShellCtrls}
- const
- DefaultMask = '*.*';
- FILE_SUPPORTS_ENCRYPTION = 32;
- FILE_SUPPORTS_OBJECT_IDS = 64;
- FILE_SUPPORTS_REPARSE_POINTS = 128;
- FILE_SUPPORTS_SPARSE_FILES = 256;
- FILE_VOLUME_QUOTAS = 512;
- SHGFI = SHGFI_SYSICONINDEX or SHGFI_SMALLICON;
- var
- drives: set of 0..25;
- CurPath: String;
- function GetMediaPresent(Value: TDiskSign) :Boolean;
- var
- ErrorMode: Word;
- bufRoot :pchar;
- a,b,c,d :dword;
- begin
- if (Value = 'A:') or (Value = 'B:')
- then
- begin
- Result := False;
- Exit;
- end;
- bufRoot := stralloc(255);
- strpcopy(bufRoot,Value + '');
- ErrorMode:=SetErrorMode(SEM_FailCriticalErrors);
- try
- try
- result:=GetDiskFreeSpace(bufRoot,a,b,c,d);
- except
- result:=False;
- end;
- finally
- strdispose(bufroot);
- SetErrorMode(ErrorMode);
- end;
- end;
- constructor TbsSkinFileListView.Create(AOwner: TComponent);
- begin
- inherited Create(AOwner);
- ReadOnly := True;
- fselectedfiles:=tStringlist.create;
- Createimages;
- ShortDateFormat:='mm/dd/yyyy';
- LongTimeFormat:='hh:nn';
- FMask:=DefaultMask;
- FSortForward:=True;
- FSortColumn:=0;
- OnCompare:=CompareFiles;
- OnColumnClick:=ColumnClick;
- if csdesigning in componentstate then fdirectory := 'c:';
- end;
- destructor TbsSkinFileListView.Destroy;
- begin
- LImageList.Free;
- SImageList.Free;
- fSelectedFiles.Free;
- inherited Destroy;
- end;
- function TbsSkinFileListView.IsFile;
- begin
- Result := Item.SubItems[5]='file';
- end;
- function TbsSkinFileListView.GetSelectedNum: Integer;
- begin
- Result:=SelCount;
- if Result=0 then
- Result:=Items.Count;
- end;
- function TbsSkinFileListView.GetSelectedSize: Integer;
- var
- i, FSize: UInt;
- FName: String;
- FInfo: TWin32FindData;
- hFindFile: THandle;
- begin
- Result:=0;
- FSize:=0;
- hFindFile:=0;
- if SelCount=0 then
- exit;
- for i:=0 to Items.Count-1 do begin
- if Items[i].selected then begin
- FName:=ExtractFileName(Items[i].SubItems[4]+#0);
- hFindFile:=FindFirstFile(pChar(FName),FInfo);
- if hFindFile<>INVALID_HANDLE_VALUE then
- FSize:=FSize+((FInfo.nFileSizeHigh*MAXDWORD)+FInfo.nFileSizeLow);
- end;
- end;
- Windows.FindClose(hFindFile);
- Result:=FSize;
- end;
- function TbsSkinFileListView.GetDirectory: String;
- begin
- Result:=FDirectory;
- end;
- procedure TbsSkinFileListView.SetDirectory(NewDir: String);
- begin
- if AnsiCompareText(NewDir,FDirectory)=0 then
- exit;
- if (UpperCase(NewDir)='DRIVES') then begin
- FDirectory:=NewDir;
- UpdateFileList;
- end else begin
- if not DirectoryExists(NewDir) then
- exit;
- NewDir:=IncludeTrailingBackslash(NewDir);
- SetCurrentDir(NewDir);
- FDirectory:=NewDir;
- UpdateFileList;
- end;
- end;
- procedure TbsSkinFileListView.SetMask(const NewMasks: String);
- begin
- if FMask<>NewMasks then begin
- FMask:=NewMasks;
- UpdateFileList;
- end;
- end;
- function TbsSkinFileListView.GetFileName: String;
- begin
- Result:=FFileName;
- end;
- procedure TbsSkinFileListView.SetFileName(NewFile: String);
- begin
- if FFileName <> NewFile then FFileName:=NewFile;
- end;
- procedure TbsSkinFileListView.SetFileType(NewFileType: TFileType);
- begin
- if NewFileType<>FFileType then begin
- FFileType:=NewFileType;
- UpdateFileList;
- end;
- end;
- procedure TbsSkinFileListView.Createimages;
- var
- SysImageList: uint;
- SFI: TSHFileInfo;
- begin
- Largeimages:=TImageList.Create(self);
- SysImageList:=SHGetFileInfo('',0,SFI,SizeOf(TSHFileInfo),SHGFI_SYSICONINDEX or SHGFI_LARGEICON);
- if SysImageList<>0 then begin
- Largeimages.Handle:=SysImageList;
- Largeimages.ShareImages:=TRUE;
- end;
- Smallimages:=TImageList.Create(Self);
- SysImageList:=SHGetFileInfo('',0,SFI,SizeOf(TSHFileInfo),SHGFI_SYSICONINDEX or SHGFI_SMALLICON);
- if SysImageList<>0 then begin
- Smallimages.Handle:=SysImageList;
- Smallimages.ShareImages:=TRUE;
- end;
- end;
- procedure TbsSkinFileListView.CreateWnd;
- begin
- inherited;
- Font.Size:=8;
- Font.Name:='MS Sans Serif';
- if Columns.Count=0 then begin
- with Columns.Add do begin
- Caption:='Name';
- Width:=200;
- end;
- with Columns.Add do begin
- Caption:='Size';
- Width:=70;
- Alignment:=taRightJustify;
- end;
- with Columns.Add do begin
- Caption:='Type';
- Width:=90;
- end;
- with Columns.Add do begin
- Caption:='Modified';
- Width:=100;
- end;
- with Columns.Add do begin
- Caption:='Attributes';
- width:=60;
- end;
- UpdateFileList;
- end;
- end;
- procedure TbsSkinFileListView.ColumnClick(Sender: TObject;
- Column: TListColumn);
- var
- required_column: integer;
- begin
- required_column:=Column.Index;
- if required_column=FSortColumn then
- FSortForward:=not FSortForward
- else begin
- FSortColumn:=required_column;
- FSortForward:=True;
- end;
- SortType:=stData;
- SortType:=stNone;
- end;
- procedure TbsSkinFileListView.CompareFiles(Sender: TObject; Item1,
- Item2: TListItem; Data: Integer; var Compare: Integer);
- var
- s1,s2,Caption1, Caption2: String;
- size1, size2: Double;
- result: integer;
- begin
- Result := 0;
- if (UpperCase(FDirectory) = 'DRIVES') then Exit;
- if (Item1.SubItems[0] = ' ') and (Item2.SubItems[0] <> ' ')
- then
- Result := -1
- else
- if (Item1.SubItems[0] <> ' ') and (Item2.SubItems[0] = ' ')
- then
- Result := 1
- else
- case FSortColumn of
- 0:
- begin
- Caption1 := AnsiUpperCase(Item1.Caption);
- Caption2 := AnsiUpperCase(Item2.Caption);
- if Caption1 > Caption2
- then
- Result := 1
- else
- if Caption1 < Caption2
- then
- Result := -1
- end;
- 1:
- begin
- s1 := Item1.SubItems[0];
- s2 := Item2.SubItems[0];
- if (s1 = '') or (s1 = ' ') then s1 := '0';
- if (s2 = '') or (s2 = ' ') then s2 := '0';
- size1 := StrToFloat(s1);
- size2 := StrToFloat(s2);
- if size1 > size2
- then Result := 1
- else Result := -1;
- end;
- 3:
- begin
- s1 := Item1.SubItems[2];
- s2 := Item2.SubItems[2];
- size1 := StrToDateTime(s1);
- size2 := StrToDateTime(s2);
- if size1 > size2
- then Result := 1
- else Result := -1;
- end;
- end;
- if FSortForward then
- Compare:= - result
- else
- Compare := result;
- end;
- procedure TbsSkinFileListView.Keydown(var Key: Word; Shift: TShiftState);
- begin
- if ((Shift=[ssCtrl]) and (key=vk_up)) or (key=vk_back) then
- OneLevelUp
- else
- if (key=vk_return) and assigned(selected) then
- DblClick;
- inherited;
- end;
- procedure TbsSkinFileListView.UpdateFileList;
- var
- oldCur: TCursor;
- MaskPtr: PChar;
- AttrIndex: TFileAttr;
- Ptr: PChar;
- DirAttr, FileAttr: DWORD;
- FName: String;
- const
- dwFileAttr: array[TFileAttr] of DWord = (FILE_ATTRIBUTE_READONLY,
- FILE_ATTRIBUTE_HIDDEN, FILE_ATTRIBUTE_SYSTEM,
- FILE_ATTRIBUTE_ARCHIVE, FILE_ATTRIBUTE_NORMAL);
- begin
- Items.beginUpdate;
- Items.Clear;
- OldCur:=Screen.Cursor;
- Screen.Cursor:=crHourGlass;
- FDirectorySize:=0;
- try
- if UpperCase(FDirectory)='DRIVES' then begin
- Column[1].Caption:='Type';
- Column[1].Width:=100;
- Column[1].Alignment:=taLeftJustify;
- Column[2].Caption:='Disk Size';
- Column[2].Width:=100;
- Column[2].Alignment:=taRightJustify;
- Column[3].Caption:='Free Space';
- Column[3].Width:=100;
- Column[3].Alignment:=taRightJustify;
- AddDrives;
- end else begin
- Column[1].Caption:='Size';
- Column[1].Width:=70;
- Column[1].Alignment:=taRightJustify;
- Column[2].Caption:='Type';
- Column[2].Width:=150;
- Column[2].Alignment:=taLeftJustify;
- Column[3].Caption:='Modified';
- Column[3].Width:=110;
- Column[3].Alignment:=taLeftJustify;
- FileAttr:=0;
- for AttrIndex:=ftReadOnly to ftNormal do
- if AttrIndex in FileType then
- FileAttr:=FileAttr or dwFileAttr[AttrIndex];
- DirAttr := FileAttr or FILE_ATTRIBUTE_DIRECTORY;
- CurPath := IncludeTrailingBackslash(FDirectory);
- FName:=CurPath+ '*.*';
- AddFile(FName, DirAttr);
- MaskPtr:=PChar(FMask);
- while MaskPtr<>nil do begin
- Ptr:=StrScan(MaskPtr,';');
- if Ptr<>nil then
- Ptr^:=#0;
- AddFile((CurPath+StrPas(MaskPtr)),FileAttr);
- if Ptr<>nil then begin
- Ptr^:=';';
- inc(Ptr);
- end;
- MaskPtr:=Ptr;
- end;
- end;
- finally
- FSortForward:=True;
- if not (UpperCase(FDirectory)='DRIVES') then
- ColumnClick(Self,Columns[0]);
- end;
- Items.EndUpdate;
- Screen.Cursor:=oldCur;
- Application.ProcessMessages;
- end;
- procedure TbsSkinFileListView.AddDrives;
- var
- shInfo: TSHFileInfo;
- NewItem: TListItem;
- i: Integer;
- Drv: String;
- DI: TDiskInfo;
- begin
- Integer(Drives):=GetLogicalDrives;
- for i:=0 to 25 do
- if (i in Drives) then begin
- Drv:=Char(i+Ord('A'))+':';
- NewItem:=Items.Add;
- try
- SHGetFileInfo(PChar(Drv+''),0,shInfo,SizeOf(shInfo),SHGFI_SYSICONINDEX or SHGFI_DISPLAYNAME or SHGFI_TYPENAME);
- if SmallImages<>nil then
- NewItem.ImageIndex:=shInfo.Iicon;
- NewItem.Caption:=StrPas(shInfo.szDisplayName);
- DI:=GetDiskInfo(TDiskSign(Drv));
- NewItem.SubItems.Add(GetMediaTypeStr(DI.MediaType));
- if (Drv <> 'A:') and (Drv <> 'B:')
- then
- begin
- NewItem.SubItems.Add(FormatFloat('###,###,##0', DI.Capacity));
- NewItem.SubItems.Add(FormatFloat('###,###,##0', DI.FreeSpace));
- end
- else
- begin
- NewItem.SubItems.Add('');
- NewItem.SubItems.Add('');
- end;
- NewItem.SubItems.Add('');
- NewItem.SubItems.Add(Drv+'');
- NewItem.SubItems.Add('drv');
- except
- Items.Delete(NewItem.Index);
- end;
- end;
- end;
- function TbsSkinFileListView.AddFile(FileMask: String; Attr: DWord): Boolean;
- var
- ShInfo: TSHFileInfo;
- attributes: String;
- FDate, FName, FileName: String;
- FSize: Integer;
- FI: TSearchRec;
- function AttrStr(Attr: integer): String;
- begin
- Result:='';
- if (FILE_ATTRIBUTE_DIRECTORY and Attr)>0 then
- Result:=Result+'';
- if (FILE_ATTRIBUTE_ARCHIVE and Attr)>0 then
- Result:=Result+'A';
- if (FILE_ATTRIBUTE_READONLY and Attr)>0 then
- Result:=Result+'R';
- if (FILE_ATTRIBUTE_HIDDEN and Attr)>0 then
- Result:=Result+'H';
- if (FILE_ATTRIBUTE_SYSTEM and Attr)>0 then
- Result:=Result+'S';
- end;
- begin
- Result := False;
- if not SetCurrentDir(FDirectory) then
- exit;
- if FindFirst(FileMask,faAnyFile,FI)=0 then
- try
- repeat
- if ((Attr and FILE_ATTRIBUTE_DIRECTORY)=(FI.Attr and FILE_ATTRIBUTE_DIRECTORY)){ and
- ((Attr and FILE_ATTRIBUTE_READONLY)>=(FI.Attr and FILE_ATTRIBUTE_READONLY)) and
- ((Attr and FILE_ATTRIBUTE_HIDDEN)>=(FI.Attr and FILE_ATTRIBUTE_HIDDEN)) and
- ((Attr and FILE_ATTRIBUTE_SYSTEM)>=(FI.Attr and FILE_ATTRIBUTE_SYSTEM))} then begin
- CurPath:=IncludeTrailingBackslash(FDirectory);
- FName:=FI.Name;
- FileName:=IncludeTrailingBackslash(FDirectory)+FName;
- if (FName='.') or (FName='..') then
- continue;
- SHGetFileInfo(PChar(FileName),0,ShInfo,SizeOf(ShInfo),SHGFI_TYPENAME or SHGFI_SYSICONINDEX or SHGFI_DISPLAYNAME);
- FSize:=FI.Size;
- FDate:=DateTimeToStr(FileDateToDateTime(FI.Time));
- Attributes:=AttrStr(FI.Attr);
- with Items.Add do begin
- Caption:=FName;
- if SmallImages<>nil then
- ImageIndex:=ShInfo.iIcon;
- if (FI.Attr and FILE_ATTRIBUTE_DIRECTORY)=FILE_ATTRIBUTE_DIRECTORY then
- SubItems.Add(' ')
- else
- SubItems.Add(Trim(IntToStr(FSize)));
- SubItems.Add((ShInfo.szTypeName));
- SubItems.Add(FDate);
- SubItems.Add(attributes);
- SubItems.Add(FileName);
- if (FI.Attr and FILE_ATTRIBUTE_DIRECTORY)=FILE_ATTRIBUTE_DIRECTORY then
- SubItems.Add('dir')
- else
- SubItems.Add('file');
- end;
- FDirectorySize:=FDirectorySize+FSize;
- Result:=True;
- end;
- until FindNext(FI)<>0;
- finally
- FindClose(FI);
- end;
- end;
- procedure TbsSkinFileListView.OneLevelUp;
- var
- NewDir: String;
- begin
- if UpperCase(Directory)='DRIVES' then
- exit;
- FDirectory:=IncludeTrailingBackslash(FDirectory);
- if (FDirectory[Length(FDirectory)-1]=':') then
- SetDirectory('Drives')
- else begin
- FDirectory:=Copy(FDirectory,1,Length(FDirectory)-1);
- NewDir:=ExtractFilePath(FDirectory);
- SetDirectory(NewDir);
- end;
- end;
- procedure TbsSkinFileListView.Click;
- begin
- if (Selected <> nil) and (Selected.SubItems[5] = 'file')
- then
- SetFileName(Selected.SubItems[4])
- else
- SetFileName('');
- inherited;
- end;
- procedure TbsSkinFileListView.DblClick;
- var
- sDir: String;
- begin
- inherited;
- if Selected=nil then
- exit;
- if (Selected.SubItems[5]='dir') or (Selected.SubItems[5]='drv') then begin
- sDir:=Selected.SubItems[4];
- sDir:=IncludeTrailingBackslash(sDir);
- SetDirectory(sDir);
- end;{ else
- if Selected.SubItems[5]='file' then
- if fcontextaction then
- PerformDefaultAction(filename, handle);}
- end;
- procedure TbsSkinFileListView.WMRButtonDown(var Message: TWMRButtonDown);
- begin
- DoMouseDown(Message, mbRight, []);
- end;
- procedure TbsSkinFileListView.DoMouseDown(var Message: TWMMouse;
- Button: TMouseButton; Shift: TShiftState);
- begin
- if not (csNoStdEvents in ControlStyle) then
- with Message do
- MouseDown(Button, KeysToShiftState(Keys) + Shift, XPos, YPos);
- end;
- function TbsSkinFileListView.GetSelectedFilenames: String;
- var
- i: integer;
- begin
- Result := '';
- fselectedfiles.clear;
- if SelCount=0 then
- exit;
- for i:=0 to Items.Count-1 do
- if Items[i].selected then begin
- fselectedfiles.add(extractfilename(Items[i].SubItems[4]));
- result:=result+Items[i].SubItems[4]+';';
- end;
- Result:=copy(result,1,length(result)-1);
- end;
- function TbsSkinFileListView.GetObjectTypes: TObjectTypes;
- var
- i: integer;
- begin
- Result:=[];
- fselectedfiles.clear;
- if SelCount=0 then
- exit;
- for i:=0 to Items.Count-1 do
- if Items[i].selected then begin
- if Items[i].SubItems[5]='file' then
- result:=result+[otfile]
- else
- if Items[i].SubItems[5]='dir' then
- result:=result+[otdirectory]
- else
- if Items[i].SubItems[5]='drv' then
- result:=result+[otdisk];
- end;
- end;
- function TbsSkinFileListView.GetDiskCap: Int64;
- begin
- Result:=GetDiskInfo(Copy(FDirectory,1,1)+':').Capacity;
- end;
- function TbsSkinFileListView.GetDiskFree: Int64;
- begin
- Result:=GetDiskInfo(Copy(FDirectory,1,1)+':').FreeSpace;
- end;
- function TbsSkinFileListView.GetDiskInfo(Value: TDiskSign): TDiskInfo;
- var
- BPS,TC,FC,SPC :integer;
- T,F :TLargeInteger;
- TF :PLargeInteger;
- bufRoot, bufVolumeLabel, bufFileSystem :pchar;
- MCL,Size,Flags :DWORD;
- s :String;
- begin
- with Result do begin
- Sign:=Value;
- Size:=255;
- bufRoot:=AllocMem(Size);
- strpcopy(bufRoot,Value+'');
- case GetDriveType(bufRoot) of
- DRIVE_UNKNOWN :MediaType:=dtUnknown;
- DRIVE_NO_ROOT_DIR :MediaType:=dtNotExists;
- DRIVE_REMOVABLE :MediaType:=dtRemovable;
- DRIVE_FIXED :MediaType:=dtFixed;
- DRIVE_REMOTE :MediaType:=dtRemote;
- DRIVE_CDROM :MediaType:=dtCDROM;
- DRIVE_RAMDISK :MediaType:=dtRAMDisk;
- end;
- FileFlags:=[];
- if GetMediaPresent(Value) then begin
- GetDiskFreeSpace(bufRoot,SectorsPerCluster,BytesPerSector,FreeClusters,TotalClusters);
- try
- new(TF);
- SysUtils.GetDiskFreeSpaceEx(bufRoot,F,T,TF);
- Capacity:=T;
- FreeSpace:=F;
- dispose(TF);
- except
- BPS:=BytesPerSector;
- TC:=TotalClusters;
- FC:=FreeClusters;
- SPC:=SectorsPerCluster;
- Capacity:=TC*SPC*BPS;
- FreeSpace:=FC*SPC*BPS;
- end;
- bufVolumeLabel:=AllocMem(Size);
- bufFileSystem:=AllocMem(Size);
- if GetVolumeInformation(bufRoot,bufVolumeLabel,Size,@Serial,MCL,Flags,bufFileSystem,Size) then begin;
- VolumeLabel:=bufVolumeLabel;
- FileSystem:=bufFileSystem;
- s:=IntToHex(Serial,8);
- SerialNumber:=copy(s,1,4)+'-'+copy(s,5,4);
- FreeMem(bufVolumeLabel);
- FreeMem(bufFileSystem);
- FreeMem(bufRoot);
- if Flags and FS_CASE_SENSITIVE=FS_CASE_SENSITIVE then
- FileFlags:=FileFlags+[fsCaseSensitive];
- if Flags and FS_CASE_IS_PRESERVED=FS_CASE_IS_PRESERVED then
- FileFlags:=FileFlags+[fsCaseIsPreserved];
- if Flags and FS_UNICODE_STORED_ON_DISK=FS_UNICODE_STORED_ON_DISK then
- FileFlags:=FileFlags+[fsUnicodeStoredOnDisk];
- if Flags and FS_PERSISTENT_ACLS=FS_PERSISTENT_ACLS then
- FileFlags:=FileFlags+[fsPersistentAcls];
- if Flags and FS_VOL_IS_COMPRESSED=FS_VOL_IS_COMPRESSED then
- FileFlags:=FileFlags+[fsVolumeIsCompressed];
- if Flags and FS_FILE_COMPRESSION=FS_FILE_COMPRESSION then
- FileFlags:=FileFlags+[fsFileCompression];
- if MCL=255 then
- FileFlags:=FileFlags+[fsLongFileNames];
- if Flags and FILE_SUPPORTS_ENCRYPTION=FILE_SUPPORTS_ENCRYPTION then
- FileFlags:=FileFlags+[fsEncryptedFileSystemSupport];
- if Flags and FILE_SUPPORTS_OBJECT_IDS=FILE_SUPPORTS_OBJECT_IDS then
- FileFlags:=FileFlags+[fsObjectIDsSupport];
- if Flags and FILE_SUPPORTS_REPARSE_POINTS=FILE_SUPPORTS_REPARSE_POINTS then
- FileFlags:=FileFlags+[fsReparsePointsSupport];
- if Flags and FILE_SUPPORTS_SPARSE_FILES=FILE_SUPPORTS_SPARSE_FILES then
- FileFlags:=FileFlags+[fsSparseFilesSupport];
- if Flags and FILE_VOLUME_QUOTAS=FILE_VOLUME_QUOTAS then
- FileFlags:=FileFlags+[fsDiskQuotasSupport];
- end;
- end else begin
- SectorsPerCluster:=0;
- BytesPerSector:=0;
- FreeClusters:=0;
- TotalClusters:=0;
- Capacity:=0;
- FreeSpace:=0;
- VolumeLabel:='';
- SerialNumber:='';
- FileSystem:='';
- Serial:=0;
- end;
- end;
- end;
- function TbsSkinFileListView.GetMediaTypeStr(MT: TMediaType): String;
- begin
- case MT of
- dtUnknown :result:='<unknown>';
- dtNotExists :result:='<not exists>';
- dtRemovable :result:='Removable';
- dtFixed :result:='Fixed';
- dtRemote :result:='Remote';
- dtCDROM :result:='CDROM';
- dtRAMDisk :result:='RAM';
- end;
- end;
- { ================================TbsSkinDirTreeView ==============================}
- const
- InvalidDOSChars = '*?/="<>|:,;+^';
- var
- FileOpMode: array[0..3] of UInt =
- (FO_COPY, FO_DELETE, FO_MOVE, FO_RENAME);
- function GetNormalIcon(Path: string): integer;
- var
- sfi: TShFileInfo;
- begin
- SHGetFileInfo(Pchar(Path), 0, sfi, SizeOf(TSHFileInfo),
- SHGFI_SYSICONINDEX or SHGFI_SMALLICON);
- Result := sfi.iIcon;
- end;
- function GetSelectedIcon(Path: string): Integer;
- var
- sfi: TShFileInfo;
- begin
- SHGetFileInfo(Pchar(Path), 0, sfi, sizeOf(TSHFileInfo),
- SHGFI_SYSICONINDEX or SHGFI_SMALLICON or SHGFI_OPENICON);
- Result := sfi.iIcon;
- end;
- function DelSlash(Path: string): string;
- begin
- Result := Path;
- if Path <> '' then
- if Path[Length(Path)] = '' then
- Delete(Result, Length(Path), 1);
- end;
- function AddSlash(Path: string): string;
- begin
- if Path = '' then exit;
- if Path[Length(Path)] <> '' then
- Result := Path + ''
- else
- Result := Path;
- end;
- function DiskinDrive(Drive: Char; ShowMsg: word): Boolean;
- var
- ErrorMode: word;
- begin
- if Drive in ['a'..'z'] then
- Dec(Drive, $20);
- if not (Drive in ['A'..'Z']) then
- MessageDlg('Not a valid Drive ID', mtError, [mbOK], 0);
- ErrorMode := SetErrorMode(SEM_FailCriticalErrors);
- try
- if DiskSize(Ord(Drive) - $40) = -1 then
- begin
- if ShowMsg > 0 then
- begin
- MessageBeep(MB_IconHand);
- MessageDlg('There is no disk in Drive or Drive is not ready', mtWarning, [mbOK], 0);
- end;
- Result := False
- end
- else
- Result := True;
- finally
- SetErrorMode(ErrorMode);
- end;
- end;
- function AddNullToStr(Path: string): string;
- begin
- if Path = '' then exit;
- if Path[Length(Path)] <> #0 then
- Result := Path + #0
- else
- Result := Path;
- end;
- function StrContains(Str1, Str2: string): Boolean;
- var
- i: Integer;
- begin
- for i := 1 to Length(Str1) do
- if Pos(Str1[i], Str2) <> 0 then
- begin
- Result := True;
- Exit;
- end;
- Result := False;
- end;
- function DoSHFileOp(Handle: THandle; OpMode: UInt; Src: string;
- Dest: string; var Aborted: Boolean): Boolean;
- var
- ipFileOp: TSHFileOpStruct;
- begin
- Src := AddNullToStr(Src);
- Dest := AddNullToStr(Dest);
- FillChar(ipFileOp, SizeOf(ipFileOp), 0);
- with ipFileOp do
- begin
- wnd := GetActiveWindow;
- wFunc := OpMode;
- pFrom := pChar(Src);
- pTo := pChar(Dest);
- fFlags := FOF_ALLOWUNDO;
- fAnyOperationsAborted := Aborted;
- hNameMappings := nil;
- lpszProgressTitle := '';
- end;
- Result := SHFileOperation(ipFileOp) = 0;
- if ipFileOp.fAnyOperationsAborted = True then
- Result := False;
- end;
- procedure TbsSkinDirTreeView.CreateWnd;
- begin
- inherited CreateWnd;
- if not (csLoading in ComponentState)
- then
- begin
- ReLoad;
- if Items.GetFirstNode <> nil then
- Items.GetFirstNode.Expand(False);
- end;
- end;
- constructor TbsSkinDirTreeView.Create;
- var
- sfi: TShFileInfo;
- hImgLst: Uint;
- begin
- inherited Create(AOwner);
- ReadOnly := True;
- Width := 180;
- Height := 120;
- Images := TImageList.Create(Self);
- hImgLst := SHGetFileInfo('', 0,
- sfi, SizeOf(sfi),
- SHGFI_SYSICONINDEX or SHGFI_SMALLICON);
- if hImgLst <> 0 then
- begin
- Images.Handle := hImgLst;
- Images.ShareImages := True;
- end;
- OnExpanding := Expanding;
- SortType := stNone;
- HideSelection := False;
- FIsNewFolder := False;
- FisCutCopy := False;
- end;
- destructor TbsSkinDirTreeView.Destroy;
- var
- i: integer;
- begin
- for i := Items.Count - 1 downto 0 do
- Items[i].Free;
- Images.Free;
- inherited Destroy;
- end;
- function TbsSkinDirTreeView.GetDirectory: String;
- begin
- Result := GetPathFromNode(Self.Selected);
- end;
- procedure TbsSkinDirTreeView.SetDirectory(Value: String);
- begin
- OpenPath(Value);
- end;
- procedure TbsSkinDirTreeView.LoadRoot;
- var
- Sfi: TSHFileInfo;
- Root: TTreenode;
- idRoot: PItemIDList;
- begin
- Items.BeginUpdate;
- Items.Clear;
- if SHGetSpecialFolderLocation(Handle, CSIDL_DRIVES, idRoot) = NOERROR then
- if SHGetFileInfo(PChar(idRoot), 0, Sfi, SizeOf(TSHFileInfo), SHGFI_PIDL
- or
- SHGFI_SYSICONINDEX or SHGFI_SMALLICON or SHGFI_DISPLAYNAME) <> 0 then
- begin
- Root := items.AddFirst(nil, Sfi.szDisplayName);
- Root.ImageIndex := Sfi.iIcon;
- Root.SelectedIndex := Sfi.iIcon;
- end;
- Items.EndUpdate;
- end;
- procedure TbsSkinDirTreeView.LoadDrives;
- var
- ADrive: integer;
- DriveLetter: char;
- DriveString: string;
- DrvName: string;
- Sfi: TSHFileInfo;
- begin
- Items.BeginUpdate;
- Integer(Drives) := GetLogicalDrives;
- for ADrive := 0 to 25 do
- begin
- if ADrive in Drives then
- begin
- DriveLetter := Chr(ADrive + ord('A'));
- DriveString := DriveLetter + ':';
- SHGetFileInfo(PChar(DriveString), 0, Sfi, SizeOf(Sfi),
- SHGFI_DISPLAYNAME);
- DrvName := Copy(Sfi.szDisplayName, 1, (Pos('(', Sfi.szDisplayName) - 1));
- with Items do
- begin
- AddChild(Items[0], ' (' + DriveLetter + ':) ' + DrvName);
- ShowButtons := True;
- Items[Count - 1].HasChildren := true;
- Items[Count - 1].ImageIndex := GetNormalIcon(DriveString);
- Items[Count - 1].SelectedIndex := GetSelectedIcon(DriveString);
- end;
- end;
- end;
- Items.EndUpdate;
- end;
- procedure TbsSkinDirTreeView.MakePath(Node: TTreeNode);
- procedure MakeSubPath;
- begin
- if Node.Level = 1 then
- TreeViewPath := Copy(Node.Text, 3, 2) + '' + TreeViewPath
- else if Node.Level > 1 then
- if TreeViewPath = '' then
- TreeViewPath := Node.Text
- else
- TreeViewPath := Node.Text + '' + TreeViewPath;
- end;
- begin
- TreeViewPath := '';
- MakeSubPath;
- while Node.Parent <> nil do
- begin
- Node := Node.Parent;
- MakeSubPath;
- end;
- end;
- procedure TbsSkinDirTreeView.AddSubs(Path: string; Node: TTreeNode);
- var
- ANode: TTreeNode;
- APath: string;
- hFindFile: THandle;
- Win32FD: TWin32FindData;
- function IsDirectory(dWin32FD: TWin32FindData): Boolean;
- var
- FName: string;
- begin
- FName := StrPas(dWin32FD.cFileName);
- with dWin32FD do
- Result := (dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY =
- FILE_ATTRIBUTE_DIRECTORY) and (FName <> '.') and (FName <> '..');
- end;
- function HasSubs(sPath: string): Boolean;
- var
- sAPath: string;
- shFindFile: THandle;
- sWin32FD: TWin32FindData;
- begin
- Result := False;
- sAPath := sPath;
- sAPath := AddSlash(sAPath);
- shFindFile := FindFirstFile(PChar(sAPath + '*.*'), sWin32FD);
- if shFindFile <> INVALID_HANDLE_VALUE then
- try
- repeat
- if IsDirectory(sWin32FD) then
- begin
- Result := True;
- Break;
- end;
- until not FindNextFile(shFindFile, sWin32FD);
- finally
- Windows.FindClose(shFindFile);
- end;
- end;
- begin
- APath := Path;
- APath := AddSlash(APath);
- hFindFile := FindFirstFile(PChar(APath + '*.*'), Win32FD);
- if hFindFile <> INVALID_HANDLE_VALUE then
- try
- repeat
- if IsDirectory(Win32FD) then
- begin
- ANode := Items.AddChild(Node, Win32FD.cFileName);
- ANode.HasChildren := HasSubs(APath + Win32FD.cFileName);
- ANode.ImageIndex := GetNormalIcon(APath + Win32FD.cFileName);
- ANode.SelectedIndex := GetSelectedIcon(APath + Win32FD.cFileName);
- end;
- until not FindNextFile(hFindFile, Win32FD);
- finally
- Windows.FindClose(hFindFile);
- end;
- end;
- procedure TbsSkinDirTreeView.ReLoad;
- begin
- Items.BeginUpdate;
- Items.Clear;
- LoadRoot;
- LoadDrives;
- Items.EndUpdate;
- end;
- procedure TbsSkinDirTreeView.Loaded;
- begin
- inherited Loaded;
- Reload;
- if Items.GetFirstNode <> nil then
- Items.GetFirstNode.Expand(False);
- end;
- procedure TbsSkinDirTreeView.Expanding(Sender: TObject; Node: TTreeNode;
- var AllowExpansion: Boolean);
- var
- OldCursor: TCursor;
- begin
- if Node.GetFirstChild = nil then
- begin
- OldCursor := Screen.Cursor;
- Screen.Cursor := crHourGlass;
- try
- MakePath(Node);
- Node.HasChildren := false;
- AddSubs(TreeViewPath, Node);
- Node.AlphaSort;
- finally
- Screen.Cursor := OldCursor;
- end;
- end;
- end;
- procedure TbsSkinDirTreeView.MouseDown(Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- var
- vHitTest: THitTests;
- DrvChar: Char;
- begin
- inherited MouseDown(button, shift, x, y);
- TreeViewPath := '';
- FPreviousPath := FSelectedPath;
- vHitTest := GetHitTestInfoAt(X, Y);
- if (htOnItem in vHitTest) or (htOnIcon in vHitTest) or
- (htOnButton in vHitTest) then
- begin
- Selected := GetNodeAt(X, Y);
- if (Selected.Level = 0) and (Items[0].getFirstChild = nil) then
- LoadDrives
- else
- MakePath(Selected);
- if Selected = Items[0] then
- FSelectedPath := 'Drives'
- else
- FSelectedPath := TreeViewPath;
- if Selected.Level = 1 then
- if GetDriveType(PChar(FSelectedPath)) in
- [DRIVE_REMOVABLE, DRIVE_CDROM] then
- begin
- DrvChar := FSelectedPath[1];
- if not DiskInDrive(DrvChar, 1) then
- begin
- OpenPath(FPreviousPath);
- exit;
- end;
- end;
- FPreviousPath := FSelectedPath;
- end;
- end;
- procedure TbsSkinDirTreeView.SetSelectedPath(Value: string);
- begin
- if AnsiCompareText(Value, FSelectedPath) = 0 then
- exit;
- FSelectedPath := Value;
- end;
- procedure TbsSkinDirTreeView.SetInitialDir(Value: string);
- begin
- if (Value = '') or (AnsiCompareText(Value, FInitialDir) = 0) then
- exit;
- Value := AddSlash(Value);
- if (not DirectoryExists(Value)) then
- exit
- else begin
- FInitialDir := Value;
- OpenPath(FInitialDir);
- end;
- end;
- procedure TbsSkinDirTreeView.OpenPath(dPath: string);
- var
- CurNode: TTreeNode;
- count: Integer;
- TempPath: string;
- CurPath: string;
- FullPath: string;
- begin
- if (dPath = '') or (Length(dPath) = 1) then exit;
- if not DirectoryExists(dPath) then exit;
- dPath := AddSlash(dPath);
- FullPath := dPath;
- Items.BeginUpdate;
- CurNode := Items.GetFirstNode; //70
- if CurNode.getFirstChild = nil then
- LoadDrives;
- {if CurNode.Expanded then
- CurNode.Collapse(True);}
- CurNode := Items.GetFirstNode;
- while Pos('', dPath) > 0 do
- begin
- count := Pos('', dPath);
- tempPath := Copy(dPath, 1, count);
- dPath := Copy(dPath, count + 1, Length(dPath));
- CurNode := CurNode.getFirstChild;
- while CurNode <> nil do
- begin
- if CurNode.Level = 1 then
- CurPath := Copy(CurNode.Text, 3, 2) + ''
- else if CurNode.Level > 1 then
- CurPath := CurNode.Text + '';
- if AnsiCompareText(CurPath, tempPath) = 0 then
- begin
- CurNode.Selected := True;
- CurNode.Expand(False);
- Break;
- end;
- CurNode := CurNode.GetNext;
- if CurNode = nil then exit;
- end;
- end;
- Items.EndUpdate;
- if AnsiCompareText(FSelectedPath, FullPath) <> 0 then
- begin
- FullPath := AddSlash(FullPath);
- FSelectedPath := FullPath;
- end;
- end;
- procedure TbsSkinDirTreeView.KeyUp(var Key: Word; Shift: TShiftState);
- var
- DrvChar: Char;
- begin
- if (Key = VK_UP) or (Key = VK_DOWN) or (Key = VK_LEFT) or (Key = VK_RIGHT) then
- begin
- inherited KeyUp(Key, Shift);
- if selected = nil then exit;
- if (Selected.Level = 0) and (Items[0].getFirstChild = nil) then
- LoadDrives
- else
- MakePath(Selected);
- if (Selected.Level = 0) then
- FSelectedPath := 'Drives'
- else
- FSelectedPath := TreeViewPath;
- if Selected.Level = 1 then
- if GetDriveType(PChar(FSelectedPath)) in
- [DRIVE_REMOVABLE, DRIVE_CDROM] then
- begin
- DrvChar := FSelectedPath[1];
- if not DiskInDrive(DrvChar, 1) then
- exit;
- end;
- end;
- if Key=VK_F5 then
- begin
- Reload;
- OpenPath(FSelectedPath);
- end;
- end;
- function TbsSkinDirTreeView.GetPathFromNode(Node: TTreeNode): string;
- begin
- Result := '';
- if Node = nil then exit;
- if Assigned(Node) then
- begin
- MakePath(Node);
- Result := TreeViewPath;
- end;
- end;
- function TbsSkinDirTreeView.CanEdit(Node: TTreeNode): Boolean;
- begin
- Result := False;
- if (Assigned(Node.Parent)) and (Node.Level > 1) and
- (not ReadOnly) then
- Result := inherited CanEdit(Node);
- end;
- procedure TbsSkinDirTreeView.Edit(const Item: TTVItem);
- var
- OldDirName: string;
- NewDirName: string;
- Aborted: Boolean;
- OldCur: TCursor;
- Rslt: Boolean;
- SelNode: TTreeNode;
- PrevNode: TTreeNode;
- function GetNodeFromItem(Item: TTVItem): TTreeNode;
- begin
- with Item do
- if (State and TVIF_PARAM) <> 0 then
- Result := Pointer(lParam)
- else
- Result := Items.GetNode(hItem);
- end;
- begin
- SelNode := GetNodeFromItem(Item);
- PrevNode := SelNode.Parent;
- if not Assigned(SelNode) then exit;
- if (SelNode = Items[0]) or (SelNode.Level = 1) then
- exit;
- if (Length(Item.pszText) = 0)
- or (StrContains(InvalidDosChars, Item.pszText)) then
- begin
- MessageBeep(MB_ICONHAND);
- if (Length(Item.pszText) > 0) then Exit;
- end;
- if SelNode <> nil then
- OldDirName := GetPathFromNode(SelNode);
- if OldDirName = '' then exit;
- OldCur := Screen.Cursor;
- Screen.Cursor := crHourGlass;
- try
- Aborted := False;
- OldDirName := DelSlash(OldDirName);
- NewDirName := ExtractFilePath(OldDirName) + Item.pszText;
- if (OldDirName <> NewDirName) and (Item.pszText <> nil)
- then
- Rslt := DoSHFileOp(Parent.Handle, FO_RENAME, OldDirName,
- NewDirName, Aborted);
- if Rslt then
- begin
- inherited Edit(Item);
- Selected := PrevNode;
- end;
- finally
- Screen.Cursor := OldCur;
- FIsNewFolder := False;
- end;
- end;
- function TbsSkinDirTreeView.AddNewNode(ParentNode: TTreeNode;
- NodeName: string): Boolean;
- var
- Path: string;
- Dir: string;
- NewNode: TTreeNode;
- begin
- Result := False;
- if ParentNode = nil then
- ParentNode := Selected;
- if ParentNode.Level = 0 then
- begin
- MessageDlg('Can''t add drives', mtError, [mbOK], 0);
- exit;
- end;
- if NodeName = '' then
- begin
- NodeName := 'New Folder';
- FIsNewFolder := True;
- end;
- try
- Path := GetPathFromNode(ParentNode);
- if Path = '' then exit;
- Path := AddSlash(Path);
- Dir := Path + NodeName;
- if StrContains(InvalidDosChars, NodeName) then
- begin
- MessageBeep(MB_ICONHAND);
- MessageDlg('Folder Name contains invalid characters', mtError, [mbOK], 0);
- exit;
- end;
- Items.BeginUpdate;
- Result := CreateDirectory(PChar(Dir), nil);
- if Result then
- begin
- ReLoad;
- Dir := AddSlash(Dir);
- OpenPath(Dir);
- NewNode := Selected;
- if (NewNode <> nil) and (NodeName = 'New Folder') then
- NewNode.EditText;
- end;
- finally
- Items.EndUpdate;
- end;
- end; {AddNewNode}
- function TbsSkinDirTreeView.DeleteNode(Node: TTreeNode): Boolean;
- var
- DelDir: string;
- DelPath: string;
- PrevNode: TTreeNode;
- oldCur: TCursor;
- Aborted: Boolean;
- begin
- Result := False;
- Aborted := True;
- PrevNode := Node.Parent;
- if (Assigned(Node)) and (Node.Level > 1) then
- begin
- oldCur := Screen.Cursor;
- Screen.Cursor := crHourGlass;
- if Selected <> nil then
- DelDir := GetPathFromNode(Selected);
- if DelDir = '' then exit;
- if not DirectoryExists(Deldir) then
- begin
- MessageBeep(MB_ICONHAND);
- MessageDlg(DelDir + 'not found', mtError, [mbOK], 0);
- Screen.Cursor := oldCur;
- Exit;
- end;
- DelDir := DelSlash(Deldir);
- DelPath := ExtractFilePath(DelDir);
- Result := DoSHFileOp(Parent.Handle, FO_DELETE, DelDir, '', Aborted);
- if Result then
- begin
- if Assigned(PrevNode) then
- Selected := PrevNode;
- Node.Delete;
- end;
- Screen.Cursor := oldCur;
- end;
- end;
- procedure TbsSkinDirTreeView.CutOrCopyNode(Mode: integer);
- begin
- FOpMode := -1;
- if (Selected = nil) or (FSelectedPath = '') then
- exit;
- FSrcPath := FSelectedPath;
- FOpMode := Mode;
- FisCutCopy := True;
- end;
- procedure TbsSkinDirTreeView.PasteNode;
- var
- Abort: Boolean;
- begin
- if (Selected = nil) or (FSelectedPath = '') or
- (FSrcPath = '') then
- begin
- FisCutCopy := False;
- exit;
- end;
- Abort := False;
- FDestPath := AddSlash(FSelectedPath);
- if DoSHFileOp(Parent.Handle, FileOpMode[FOpMode], FSrcPath, FDestPath, Abort) then
- begin
- Reload;
- OpenPath(FDestPath)
- end else
- MessageDlg('File operation failed', mtError, [mbOK], 0);
- FisCutCopy := False;
- end;
- constructor TbsSkinShellDriveComboBox.Create(AOwner: TComponent);
- begin
- inherited Create(AOwner);
- Style := bscbFixedStyle;
- OnListBoxDrawItem := DrawItem;
- OnComboBoxDrawItem := DrawItem;
- Drives := TStringList.Create;
- Images := TImagelist.CreateSize(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON));
- with Images do
- begin
- DrawingStyle := dsTransparent;
- ShareImages := True;
- end;
- end;
- destructor TbsSkinShellDriveComboBox.Destroy;
- begin
- Drives.Free;
- Images.Free;
- inherited Destroy;
- end;
- procedure TbsSkinShellDriveComboBox.BuildList;
- var
- Info : TSHFileInfo;
- DriveChar : Char;
- CurrDrive : string;
- DriveType:Integer;
- begin
- if Items.Count > 0
- then
- begin
- if ItemIndex > -1 then DriveItemIndex := ItemIndex;
- Items.Clear;
- end;
- Images.Handle := SHGetFileInfo('', 0, Info, SizeOf(TShFileInfo), SHGFI);
- for DriveChar:='A' to 'Z' do
- begin
- CurrDrive := DriveChar + ':';
- DriveType := GetDriveType(PChar(CurrDrive));
- if DriveType in [0,1] then Continue;
- SHGetFileInfo(PChar(CurrDrive), 0, Info, SizeOf(TShFileInfo), SHGFI_DISPLAYNAME or SHGFI);
- Items.AddObject(Info.szDisplayName, TObject(Info.iIcon));
- Drives.Add(DriveChar);
- end;
- SetDrive(Drives[DriveItemIndex][1]);
- Update;
- end;
- procedure TbsSkinShellDriveComboBox.CreateWnd;
- begin
- inherited CreateWnd;
- BuildList;
- end;
- procedure TbsSkinShellDriveComboBox.DrawItem;
- var
- ImageTop: Integer;
- begin
- if Images.Count > 0
- then
- begin
- ImageTop := TextRect.Top + ((TextRect.Bottom - TextRect.Top - Images.Height) div 2);
- Images.Draw(Cnvs, TextRect.Left, ImageTop, Integer(Items.Objects[Index]));
- TextRect.Left := TextRect.Left + Images.Width + 4;
- end;
- Cnvs.TextOut(TextRect.Left,
- TextRect.Top + (TextRect.Bottom - TextRect.Top) div 2 - Cnvs.TextHeight('Wg') div 2,
- Items[Index]);
- end;
- procedure TbsSkinShellDriveComboBox.SetDrive(Value: Char);
- var
- i: Integer;
- j: Integer;
- begin
- j := 0;
- if DriveItemIndex <> -1 then j := DriveItemIndex;
- Value := UpCase(Value);
- if FDrive <> Value
- then
- begin
- for i := 0 to Items.Count - 1 do
- if Drives[i][1] = Value
- then
- begin
- FDrive := Value;
- DriveItemIndex := i;
- ItemIndex := i;
- Exit;
- end;
- end
- else
- if ItemIndex <> j then ItemIndex := j;
- end;
- procedure TbsSkinShellDriveComboBox.Change;
- begin
- if ItemIndex <> -1 then DriveItemIndex := ItemIndex;
- SetDrive(Drives[DriveItemIndex][1]);
- if Assigned(FOnChange) then FOnChange(Self);
- end;
- procedure TbsSkinShellDriveComboBox.UpdateDrives;
- var
- Info : TSHFileInfo;
- begin
- if Assigned(Images) then Images.Free;
- Images := TImagelist.CreateSize(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON));
- with Images do
- begin
- DrawingStyle := dsTransparent;
- ShareImages := True;
- end;
- Images.Handle := SHGetFileInfo('', 0, Info, SizeOf(TShFileInfo), SHGFI);
- BuildList;
- end;
- {Dialogs}
- constructor TbsSelDirDlgForm.Create(AOwner: TComponent);
- begin
- inherited CreateNew(AOwner);
- KeyPreview := True;
- // BorderStyle := bsDialog;
- Position := poScreenCenter;
- BSF := TbsBusinessSkinForm.Create(Self);
- DirTreeViewPanel := TbsSkinPanel.Create(Self);
- with DirTreeViewPanel do
- begin
- Parent := Self;
- Align := alClient;
- BorderStyle := bvFrame;
- Height := 200;
- end;
- VScrollBar := TbsSkinScrollBar.Create(Self);
- with VScrollBar do
- begin
- Kind := sbVertical;
- Parent := DirTreeViewPanel;
- Align := alRight;
- DefaultWidth := 19;
- Enabled := False;
- SkinDataName := 'vscrollbar';
- end;
- HScrollBar := TbsSkinScrollBar.Create(Self);
- with HScrollBar do
- begin
- Parent := DirTreeViewPanel;
- Align := alBottom;
- DefaultHeight := 19;
- Enabled := False;
- BothMarkerWidth := 19;
- SkinDataName := 'hscrollbar';
- end;
- DirTreeView := TbsSkinDirTreeView.Create(Self);
- with DirTreeView do
- begin
- Parent := DirTreeViewPanel;
- Align := alClient;
- HScrollBar := Self.HScrollBar;
- VScrollBar := Self.VScrollBar;
- HideSelection := False;
- end;
- BottomPanel := TbsSkinPanel.Create(Self);
- with BottomPanel do
- begin
- Parent := Self;
- Align := alBottom;
- BorderStyle := bvNone;
- Height := 50;
- end;
- OkButton := TbsSkinButton.Create(Self);
- with OkButton do
- begin
- Default := True;
- Caption := 'Ok';
- CanFocused := True;
- Left := 20;
- Top := 15;
- Width := 70;
- DefaultHeight := 25;
- Parent := BottomPanel;
- ModalResult := mrOk;
- end;
- CancelButton := TbsSkinButton.Create(Self);
- with CancelButton do
- begin
- Caption := 'Cancel';
- CanFocused := True;
- Left := 100;
- Top := 15;
- Width := 70;
- DefaultHeight := 25;
- Parent := BottomPanel;
- ModalResult := mrCancel;
- Cancel := True;
- end;
- end;
- constructor TbsSkinSelectDirectoryDialog.Create(AOwner: TComponent);
- begin
- inherited Create(AOwner);
- DialogWidth := 0;
- DialogHeight := 0;
- FAlphaBlend := False;
- FAlphaBlendAnimation := False;
- FAlphaBlendValue := 200;
- FTitle := 'Select folder';
- FDefaultFont := TFont.Create;
- with FDefaultFont do
- begin
- Name := 'Arial';
- Style := [];
- Height := 14;
- end;
- FDirectory := '';
- end;
- destructor TbsSkinSelectDirectoryDialog.Destroy;
- begin
- FDefaultFont.Free;
- inherited Destroy;
- end;
- procedure TbsSkinSelectDirectoryDialog.SetDefaultFont;
- begin
- FDefaultFont.Assign(Value);
- end;
- procedure TbsSkinSelectDirectoryDialog.Notification;
- begin
- inherited Notification(AComponent, Operation);
- if (Operation = opRemove) and (AComponent = FSD) then FSD := nil;
- if (Operation = opRemove) and (AComponent = FCtrlFSD) then FCtrlFSD := nil;
- end;
- function TbsSkinSelectDirectoryDialog.GetTitle: string;
- begin
- Result := FTitle;
- end;
- procedure TbsSkinSelectDirectoryDialog.SetTitle(const Value: string);
- begin
- FTitle := Value;
- end;
- procedure TbsSkinSelectDirectoryDialog.Change;
- begin
- if Assigned(FOnChange) then FOnChange(Self);
- end;
- function TbsSkinSelectDirectoryDialog.Execute: Boolean;
- var
- FW, FH: Integer;
- begin
- FDlgFrm := TbsSelDirDlgForm.Create(Application);
- with FDlgFrm do
- try
- Caption := Self.Title;
- BSF.BorderIcons := [];
- BSF.SkinData := FSD;
- BSF.MenusSkinData := CtrlSkinData;
- BSF.AlphaBlend := AlphaBlend;
- BSF.AlphaBlendAnimation := AlphaBlendAnimation;
- BSF.AlphaBlendValue := AlphaBlendValue;
- //
- DirTreeViewPanel.SkinData := FCtrlFSD;
- DirTreeView.DefaultFont := DefaultFont;
- DirTreeView.SkinData := FCtrlFSD;
- DirTreeView.Color := clWindow;
- if FDirectory <> '' then DirTreeView.OpenPath(FDirectory);
- //
- HScrollBar.SkinData := FCtrlFSD;
- VScrollBar.SkinData := FCtrlFSD;
- OkButton.SkinData := FCtrlFSD;
- CancelButton.SkinData := FCtrlFSD;
- BottomPanel.SkinData := FCtrlFSD;
- OkButton.DefaultFont := DefaultFont;
- CancelButton.DefaultFont := DefaultFont;
- if (DialogWidth <> 0)
- then
- begin
- FW := DialogWidth;
- FH := DialogHeight;
- end
- else
- begin
- FW := 250;
- FH := 250;
- end;
- if (SkinData <> nil) and not SkinData.Empty
- then
- begin
- if FW < BSF.GetMinWidth then FW := BSF.GetMinWidth;
- if FH < BSF.GetMinHeight then FH := BSF.GetMinHeight;
- end;
- ClientWidth := FW;
- ClientHeight := FH;
- Result := (ShowModal = mrOk);
- DialogWidth := ClientWidth;
- DialogHeight := ClientHeight;
- if Result
- then
- begin
- FDirectory := FDlgFrm.DirTreeView.Directory;
- Change;
- end;
- finally
- Free;
- FDlgFrm := nil;
- end;
- end;
- constructor TbsOpenDlgForm.CreateEx(AOwner: TComponent; ASaveMode: Boolean);
- begin
- inherited CreateNew(AOwner);
- SaveMode := ASaveMode;
- KeyPreview := True;
- // BorderStyle := bsDialog;
- Position := poScreenCenter;
- BSF := TbsBusinessSkinForm.Create(Self);
- FromFLV := False;
- FromFTV := False;
- ToolPanel := TbsSkinPanel.Create(Self);
- with ToolPanel do
- begin
- BorderStyle := bvNone;
- Parent := Self;
- Align := alTop;
- DefaultHeight := 25;
- SkinDataName := 'toolpanel';
- OnResize := ToolPanelOnResize;
- end;
- BackToolButton := TbsSkinSpeedButton.Create(Self);
- with BackToolButton do
- begin
- Parent := ToolPanel;
- DefaultHeight := 25;
- DefaultWidth := 70;
- SkinDataName := 'toolbutton';
- Align := alLeft;
- OnClick := BackToolButtonClick;
- NumGlyphs := 1;
- Glyph.LoadFromResourceName(HInstance, 'BS_UP');
- end;
- SortNameToolButton := TbsSkinSpeedButton.Create(Self);
- with SortNameToolButton do
- begin
- Parent := ToolPanel;
- DefaultWidth := 27;
- SkinDataName := 'toolbutton';
- Align := alRight;
- OnClick := SortNameToolButtonClick;
- NumGlyphs := 1;
- Glyph.LoadFromResourceName(HInstance, 'BS_SORTNAME');
- end;
- SortSizeToolButton := TbsSkinSpeedButton.Create(Self);
- with SortSizeToolButton do
- begin
- Parent := ToolPanel;
- DefaultWidth := 27;
- SkinDataName := 'toolbutton';
- Align := alRight;
- OnClick := SortSizeToolButtonClick;
- NumGlyphs := 1;
- Glyph.LoadFromResourceName(HInstance, 'BS_SORTSIZE');
- end;
- SortDateToolButton := TbsSkinSpeedButton.Create(Self);
- with SortDateToolButton do
- begin
- Parent := ToolPanel;
- DefaultWidth := 27;
- SkinDataName := 'toolbutton';
- Align := alRight;
- OnClick := SortDateButtonClick;
- NumGlyphs := 1;
- Glyph.LoadFromResourceName(HInstance, 'BS_SORTDATE');
- end;
- //
- Bevel1 := TbsSkinBevel.Create(Self);
- with Bevel1 do
- begin
- Parent := ToolPanel;
- Width := 27;
- Align := alRight;
- DividerMode := True;
- end;
- //
- ListToolButton := TbsSkinSpeedButton.Create(Self);
- with ListToolButton do
- begin
- Parent := ToolPanel;
- DefaultWidth := 27;
- SkinDataName := 'toolbutton';
- Align := alRight;
- GroupIndex := 1;
- Down := True;
- OnClick := ListToolButtonClick;
- NumGlyphs := 1;
- Glyph.LoadFromResourceName(HInstance, 'BS_LISTSTYLE');
- end;
- SmallIconToolButton := TbsSkinSpeedButton.Create(Self);
- with SmallIconToolButton do
- begin
- Parent := ToolPanel;
- DefaultWidth := 27;
- SkinDataName := 'toolbutton';
- Align := alRight;
- GroupIndex := 1;
- OnClick := SmallIconToolButtonClick;
- NumGlyphs := 1;
- Glyph.LoadFromResourceName(HInstance, 'BS_SMALLICONSTYLE');
- end;
- IconToolButton := TbsSkinSpeedButton.Create(Self);
- with IconToolButton do
- begin
- Parent := ToolPanel;
- DefaultWidth := 27;
- SkinDataName := 'toolbutton';
- Align := alRight;
- GroupIndex := 1;
- OnClick := IconToolButtonClick;
- NumGlyphs := 1;
- Glyph.LoadFromResourceName(HInstance, 'BS_ICONSTYLE');
- end;
- ReportToolButton := TbsSkinSpeedButton.Create(Self);
- with ReportToolButton do
- begin
- Parent := ToolPanel;
- DefaultWidth := 27;
- SkinDataName := 'toolbutton';
- Align := alRight;
- GroupIndex := 1;
- OnClick := ReportToolButtonClick;
- NumGlyphs := 1;
- Glyph.LoadFromResourceName(HInstance, 'BS_REPORTSTYLE');
- end;
- Bevel2 := TbsSkinBevel.Create(Self);
- with Bevel2 do
- begin
- Parent := ToolPanel;
- Width := 26;
- Align := alRight;
- DividerMode := True;
- end;
- Bevel3 := TbsSkinBevel.Create(Self);
- with Bevel3 do
- begin
- Parent := ToolPanel;
- Width := 26;
- Align := alLeft;
- DividerMode := True;
- end;
- DriveBox := TbsSkinShellDriveComboBox.Create(Self);
- with DriveBox do
- begin
- Parent := ToolPanel;
- OnChange := DCBChange;
- end;
- BottomPanel := TbsSkinPanel.Create(Self);
- with BottomPanel do
- begin
- Parent := Self;
- Align := alBottom;
- BorderStyle := bvNone;
- Height := 80;
- end;
- Splitter := TbsSkinSplitter.Create(Self);
- with Splitter do
- begin
- Parent := Self;
- Align := alLeft;
- Width := 10;
- DefaultSize := 10;
- Beveled := False;
- end;
- DirTreeViewPanel := TbsSkinExPanel.Create(Self);
- with DirTreeViewPanel do
- begin
- Parent := Self;
- Align := alLeft;
- RollKind := rkRollHorizontal;
- ShowCloseButton := False;
- Width := 200;
- end;
- FileListViewPanel := TbsSkinPanel.Create(Self);
- with FileListViewPanel do
- begin
- Parent := Self;
- Align := alClient;
- BorderStyle := bvFrame;
- end;
- DTVVScrollBar := TbsSkinScrollBar.Create(Self);
- with DTVVScrollBar do
- begin
- Kind := sbVertical;
- Parent := DirTreeViewPanel;
- Align := alRight;
- DefaultWidth := 19;
- Enabled := False;
- SkinDataName := 'vscrollbar';
- end;
- DTVHScrollBar := TbsSkinScrollBar.Create(Self);
- with DTVHScrollBar do
- begin
- Parent := DirTreeViewPanel;
- Align := alBottom;
- DefaultHeight := 19;
- Enabled := False;
- BothMarkerWidth := 19;
- SkinDataName := 'hscrollbar';
- end;
- DirTreeView := TbsSkinDirTreeView.Create(Self);
- with DirTreeView do
- begin
- Parent := DirTreeViewPanel;
- Align := alClient;
- HScrollBar := Self.DTVHScrollBar;
- VScrollBar := Self.DTVVScrollBar;
- OnChange := DTVChange;
- HideSelection := False;
- end;
- FLVHScrollBar := TbsSkinScrollBar.Create(Self);
- with FLVHScrollBar do
- begin
- BothMarkerWidth := 19;
- Parent := FileListViewPanel;
- Align := alBottom;
- DefaultHeight := 19;
- Enabled := False;
- SkinDataName := 'hscrollbar';
- end;
- FLVVScrollBar := TbsSkinScrollBar.Create(Self);
- with FLVVScrollBar do
- begin
- Kind := sbVertical;
- Parent := FileListViewPanel;
- Align := alRight;
- DefaultWidth := 19;
- Enabled := False;
- SkinDataName := 'vscrollbar';
- end;
- FileListView := TbsSkinFileListView.Create(Self);
- with FileListView do
- begin
- Parent := FileListViewPanel;
- ViewStyle := vsList;
- ShowColumnHeaders := True;
- IconOptions.AutoArrange := True;
- GridLines := True;
- Align := alClient;
- HScrollBar := FLVHScrollBar;
- VScrollBar := FLVVScrollBar;
- OnChange := FLVChange;
- OnDblClick := FLVDBLClick;
- HideSelection := False;
- end;
- FileNameEdit := TbsSkinEdit.Create(Self);
- with FileNameEdit do
- begin
- Parent := BottomPanel;
- Top := 10;
- Left := 70;
- Width := 300;
- DefaultHeight := 21;
- OnKeyPress := EditKeyPress;
- end;
- FilterComboBox := TbsSkinFilterComboBox.Create(Self);
- with FilterComboBox do
- begin
- Parent := BottomPanel;
- Top := 45;
- Left := 70;
- Width := 300;
- DefaultHeight := 21;
- OnChange := FCBChange;
- end;
- OpenButton := TbsSkinButton.Create(Self);
- with OpenButton do
- begin
- if SaveMode
- then
- Caption := '&Save'
- else
- Caption := '&Open';
- CanFocused := True;
- Left := 390;
- Top := 10;
- Width := 70;
- DefaultHeight := 25;
- Parent := BottomPanel;
- OnClick := OpenButtonClick;
- end;
- CancelButton := TbsSkinButton.Create(Self);
- with CancelButton do
- begin
- Caption := 'Cancel';
- CanFocused := True;
- Left := 390;
- Top := 45;
- Width := 70;
- DefaultHeight := 25;
- Parent := BottomPanel;
- ModalResult := mrCancel;
- Cancel := True;
- end;
- OpenFileLabel := TbsSkinStdLabel.Create(Self);
- with OpenFileLabel do
- begin
- Caption := 'File name:';
- Left := 10;
- Top := 10;
- AutoSize := True;
- Parent := BottomPanel;
- end;
- FileTypeLabel := TbsSkinStdLabel.Create(Self);
- with FileTypeLabel do
- begin
- Caption := 'File type:';
- Left := 10;
- Top := 45;
- AutoSize := True;
- Parent := BottomPanel;
- end;
- ActiveControl := FileNameEdit;
- end;
- procedure TbsOpenDlgForm.SortNameToolButtonClick(Sender: TObject);
- begin
- FileListView.ColumnClick(Sender, FileListView.Columns[0]);
- end;
- procedure TbsOpenDlgForm.SortSizeToolButtonClick(Sender: TObject);
- begin
- FileListView.ColumnClick(Sender, FileListView.Columns[1]);
- end;
- procedure TbsOpenDlgForm.SortDateButtonClick(Sender: TObject);
- begin
- FileListView.ColumnClick(Sender, FileListView.Columns[3]);
- end;
- procedure TbsOpenDlgForm.ReportToolButtonClick(Sender: TObject);
- begin
- FileListView.ViewStyle := vsReport;
- FileListView.UpdateScrollBars;
- end;
- procedure TbsOpenDlgForm.BackToolButtonClick(Sender: TObject);
- begin
- FileListView.OneLevelUp;
- FileListView.UpdateScrollBars;
- end;
- procedure TbsOpenDlgForm.ListToolButtonClick(Sender: TObject);
- begin
- FileListView.ViewStyle := vsList;
- FileListView.UpdateScrollBars;
- end;
- procedure TbsOpenDlgForm.SmallIconToolButtonClick(Sender: TObject);
- begin
- FileListView.ViewStyle := vsSmallIcon;
- FileListView.UpdateScrollBars;
- end;
- procedure TbsOpenDlgForm.IconToolButtonClick(Sender: TObject);
- begin
- FileListView.ViewStyle := vsIcon;
- end;
- procedure TbsOpenDlgForm.EditKeyPress;
- var
- FileName: String;
- begin
- inherited;
- if Key = #13
- then
- begin
- if Pos('*', FileNameEdit.Text) <> 0
- then
- FileListView.Mask := FileNameEdit.Text
- else
- begin
- FileName := Self.FileListView.Directory + FileNameEdit.Text;
- if FileExists(FileName)
- then
- OpenButtonClick(Sender)
- else
- if DirectoryExists(FileNameEdit.Text)
- then
- FileListView.Directory := FileNameEdit.Text;
- end;
- end;
- end;
- procedure TbsOpenDlgForm.OpenButtonClick;
- var
- S: String;
- begin
- if FileNameEdit.Text = '' then Exit;
- if SaveMode
- then
- begin
- S := Self.FileListView.Directory + FileNameEdit.Text;
- if (Pos('*', S) = 0)
- then
- begin
- FileName := Self.FileListView.Directory + FileNameEdit.Text;
- ModalResult := mrOk;
- end;
- end
- else
- begin
- FileName := Self.FileListView.Directory + FileNameEdit.Text;
- if FileExists(FileName) then ModalResult := mrOk else FileName := '';
- end;
- end;
- procedure TbsOpenDlgForm.ToolPanelOnResize;
- begin
- if (DriveBox <> nil) and (Bevel2 <> nil) and (Bevel3 <> nil)
- then
- DriveBox.SetBounds(Bevel3.left + Bevel3.Width,
- ToolPanel.Height div 2 - DriveBox.Height div 2,
- Bevel2.Left - Bevel3.Left - Bevel3.Width,
- DriveBox.Height);
- end;
- procedure TbsOpenDlgForm.DCBChange(Sender: TObject);
- begin
- FromDCB := True;
- if not FromFLV and not FromFTV and (DirTreeView <> nil)
- then DirTreeView.Directory := DriveBox.Drive + ':';
- FromDCB := False;
- end;
- procedure TbsOpenDlgForm.FLVChange;
- var
- OldPosition: Integer;
- C: TCanvas;
- begin
- FromFLV := True;
- if (not FromFTV) and (DirTreeView.FSelectedPath <> FileListView.Directory)
- then
- begin
- DirTreeView.Directory := FileListView.Directory;
- DirTreeViewPanel.Caption := DirTreeView.Selected.Text;
- end;
- if FileListView.Selected <> nil
- then
- if FileListView.IsFile(FileListView.Selected)
- then
- FileNameEdit.Text := FileListView.Selected.Caption
- else
- FileNameEdit.Text := '';
- FromFLV := False;
- end;
- procedure TbsOpenDlgForm.FLVDBLClick(Sender: TObject);
- begin
- if (FileListView.Selected <> nil) and
- (FileListView.Selected.SubItems[5] = 'file')
- then
- begin
- FileNameEdit.Text := FileListView.Selected.Caption;
- FileName := Self.FileListView.Directory + FileNameEdit.Text;
- ModalResult := mrOk;
- end;
- end;
- procedure TbsOpenDlgForm.DTVChange;
- begin
- FromFTV := True;
- if not FromFLV
- then
- begin
- FileListView.Directory := DirTreeView.GetPathFromNode(Node);
- DirTreeViewPanel.Caption := DirTreeView.Selected.Text;
- end;
- if not FromDCB and (DriveBox <> nil) and (DriveBox.Drives.Count > 0)
- and (DirTreeView.Directory <> '')
- then
- DriveBox.Drive := DirTreeView.Directory[1];
- FromFTV := False;
- end;
- procedure TbsOpenDlgForm.FCBChange(Sender: TObject);
- begin
- FileListView.Mask := FilterComboBox.Mask;
- end;
- constructor TbsSkinOpenDialog.Create(AOwner: TComponent);
- begin
- inherited Create(AOwner);
- DialogWidth := 0;
- DialogHeight := 0;
- FLVHeaderSkinDataName := 'resizebutton';
- FAlphaBlend := False;
- FAlphaBlendAnimation := False;
- FAlphaBlendValue := 200;
- FSaveMode := False;
- FTitle := 'Open file';
- FDefaultFont := TFont.Create;
- with FDefaultFont do
- begin
- Name := 'Arial';
- Style := [];
- Height := 14;
- end;
- FInitialDir := '';
- FFilter := 'All files|*.*';
- FFilterIndex := 0;
- FFileName := '';
- TreePanelWidth := 200;
- ListViewStyle := vsList;
- end;
- destructor TbsSkinOpenDialog.Destroy;
- begin
- FDefaultFont.Free;
- inherited Destroy;
- end;
- procedure TbsSkinOpenDialog.SetDefaultFont;
- begin
- FDefaultFont.Assign(Value);
- end;
- procedure TbsSkinOpenDialog.Notification;
- begin
- inherited Notification(AComponent, Operation);
- if (Operation = opRemove) and (AComponent = FSD) then FSD := nil;
- if (Operation = opRemove) and (AComponent = FCtrlFSD) then FCtrlFSD := nil;
- end;
- function TbsSkinOpenDialog.GetTitle: string;
- begin
- Result := FTitle;
- end;
- procedure TbsSkinOpenDialog.SetTitle(const Value: string);
- begin
- FTitle := Value;
- end;
- procedure TbsSkinOpenDialog.Change;
- begin
- if Assigned(FOnChange) then FOnChange(Self);
- end;
- function TbsSkinOpenDialog.Execute: Boolean;
- var
- FW, FH: Integer;
- Path: String;
- begin
- FDlgFrm := TbsOpenDlgForm.CreateEx(Application, FSaveMode);
- with FDlgFrm do
- try
- Caption := Self.Title;
- BSF.BorderIcons := [];
- BSF.SkinData := FSD;
- BSF.MenusSkinData := CtrlSkinData;
- BSF.AlphaBlend := AlphaBlend;
- BSF.AlphaBlendAnimation := AlphaBlendAnimation;
- BSF.AlphaBlendValue := AlphaBlendValue;
- DirTreeView.SkinData := FCtrlFSD;
- DirTreeView.Color := clWindow;
- DirTreeViewPanel.Width := TreePanelWidth;
- DirTreeViewPanel.RollState := TreePanelRollState;
- case ListViewStyle of
- vsList: ListToolButton.Down := True;
- vsReport: ReportToolButton.Down := True;
- vsIcon: IconToolButton.Down := True;
- vsSmallIcon: SmallIconToolButton.Down := True;
- end;
- FileListView.ViewStyle := ListViewStyle;
- if (FFileName <> '') and (ExtractFilePath(FFileName) <> '')
- then
- begin
- Path := ExtractFilePath(FFileName);
- FileListView.Directory := Path;
- FileNameEdit.Text := ExtractFileName(FFileName);
- end
- else
- begin
- if FInitialDir = ''
- then
- FileListView.Directory := ExtractFilePath(Application.ExeName)
- else
- FileListView.Directory := FInitialDir;
- FileNameEdit.Text := FFileName;
- end;
- FromFLV := True;
- if FileListView.Directory <> ''
- then
- DriveBox.Drive := FileListView.Directory[1]
- else
- DriveBox.Drive := 'C';
- FromFLV := False;
- FileListView.HeaderSkinDataName := FLVHeaderSkinDataName;
- FileListView.SkinData := FCtrlFSD;
- FilterComboBox.Filter := Self.Filter;
- FilterComboBox.ItemIndex := FFilterIndex;
- //
- DirTreeViewPanel.SkinData := FCtrlFSD;
- FileListViewPanel.SkinData := FCtrlFSD;
- BottomPanel.SkinData := FCtrlFSD;
- ToolPanel.SkinData := FCtrlFSD;
- Bevel1.SkinData := FCtrlFSD;
- Bevel2.SkinData := FCtrlFSD;
- Bevel3.SkinData := FCtrlFSD;
- DriveBox.SkinData := FCtrlFSD;
- BackToolButton.SkinData := FCtrlFSD;
- ListToolButton.SkinData := FCtrlFSD;
- ReportToolButton.SkinData := FCtrlFSD;
- IconToolButton.SkinData := FCtrlFSD;
- SmallIconToolButton.SkinData := FCtrlFSD;
- SortNameToolButton.SkinData := FCtrlFSD;
- SortSizeToolButton.SkinData := FCtrlFSD;
- SortDateToolButton.SkinData := FCtrlFSD;
- //
- Splitter.SkinData := FCtrlFSD;
- DTVHScrollBar.SkinData := FCtrlFSD;
- DTVVScrollBar.SkinData := FCtrlFSD;
- FLVHScrollBar.SkinData := FCtrlFSD;
- FLVVScrollBar.SkinData := FCtrlFSD;
- FileNameEdit.SkinData := FCtrlFSD;
- FilterComboBox.SkinData := FCtrlFSD;
- OpenButton.SkinData := FCtrlFSD;
- CancelButton.SkinData := FCtrlFSD;
- OpenFileLabel.SkinData := FCtrlFSD;
- FileTypeLabel.SkinData := FCtrlFSD;
- //
- if (DialogWidth <> 0)
- then
- begin
- FW := DialogWidth;
- FH := DialogHeight;
- end
- else
- begin
- FW := 500;
- FH := 300;
- end;
- if (SkinData <> nil) and not SkinData.Empty
- then
- begin
- if FW < BSF.GetMinWidth then FW := BSF.GetMinWidth;
- if FH < BSF.GetMinHeight then FH := BSF.GetMinHeight;
- end;
- ClientWidth := FW;
- ClientHeight := FH;
- Result := (ShowModal = mrOk);
- if DirTreeViewPanel.RollState
- then
- TreePanelWidth := DirTreeViewPanel.RealWidth
- else
- TreePanelWidth := DirTreeViewPanel.Width;
- DialogWidth := ClientWidth;
- DialogHeight := ClientHeight;
- TreePanelRollState := DirTreeViewPanel.RollState;
- ListViewStyle := FileListView.ViewStyle;
- if Result
- then
- begin
- Self.FFileName := FDlgFrm.FileName;
- Change;
- end;
- finally
- Free;
- FDlgFrm := nil;
- end;
- end;
- constructor TbsSkinSaveDialog.Create(AOwner: TComponent);
- begin
- inherited;
- FTitle := 'Save file';
- FSaveMode := True;
- end;
- constructor TbsSkinDirectoryEdit.Create(AOwner: TComponent);
- begin
- inherited;
- ControlStyle := ControlStyle - [csSetCaption];
- ButtonMode := True;
- OnButtonClick := ButtonClick;
- FSkinDataName := 'buttonedit';
- SD := TbsSkinSelectDirectoryDialog.Create(Self);
- end;
- destructor TbsSkinDirectoryEdit.Destroy;
- begin
- SD.Free;
- inherited;
- end;
- procedure TbsSkinDirectoryEdit.ButtonClick;
- begin
- SD.Directory := Text;
- SD.SkinData := FDlgSkinData;
- SD.CtrlSkinData := FDlgCtrlSkinData;
- if SD.Execute then Text := SD.Directory;
- end;
- procedure TbsSkinDirectoryEdit.Notification;
- begin
- inherited Notification(AComponent, Operation);
- if (Operation = opRemove) and (AComponent = FDlgSkinData) then FDlgSkinData := nil;
- if (Operation = opRemove) and (AComponent = FDlgCtrlSkinData) then FDlgCtrlSkinData := nil;
- end;
- constructor TbsSkinFileEdit.Create(AOwner: TComponent);
- begin
- inherited;
- ControlStyle := ControlStyle - [csSetCaption];
- ButtonMode := True;
- OnButtonClick := ButtonClick;
- FSkinDataName := 'buttonedit';
- FLVHeaderSkinDataName := 'resizebutton';
- OD := TbsSkinOpenDialog.Create(Self);
- end;
- destructor TbsSkinFileEdit.Destroy;
- begin
- OD.Free;
- inherited;
- end;
- function TbsSkinFileEdit.GetFilter;
- begin
- Result := OD.Filter;
- end;
- procedure TbsSkinFileEdit.SetFilter;
- begin
- OD.Filter := Value;
- end;
- procedure TbsSkinFileEdit.ButtonClick;
- begin
- OD.FileName := Text;
- OD.SkinData := FDlgSkinData;
- OD.CtrlSkinData := FDlgCtrlSkinData;
- OD.LVHeaderSkinDataName := FLVHeaderSkinDataName;
- if OD.Execute then Text := OD.FileName;
- end;
- procedure TbsSkinFileEdit.Notification;
- begin
- inherited Notification(AComponent, Operation);
- if (Operation = opRemove) and (AComponent = FDlgSkinData) then FDlgSkinData := nil;
- if (Operation = opRemove) and (AComponent = FDlgCtrlSkinData) then FDlgCtrlSkinData := nil;
- end;
- constructor TbsSkinSaveFileEdit.Create(AOwner: TComponent);
- begin
- inherited;
- ControlStyle := ControlStyle - [csSetCaption];
- FLVHeaderSkinDataName := 'resizebutton';
- ButtonMode := True;
- OnButtonClick := ButtonClick;
- FSkinDataName := 'buttonedit';
- OD := TbsSkinSaveDialog.Create(Self);
- end;
- destructor TbsSkinSaveFileEdit.Destroy;
- begin
- OD.Free;
- inherited;
- end;
- function TbsSkinSaveFileEdit.GetFilter;
- begin
- Result := OD.Filter;
- end;
- procedure TbsSkinSaveFileEdit.SetFilter;
- begin
- OD.Filter := Value;
- end;
- procedure TbsSkinSaveFileEdit.ButtonClick;
- begin
- OD.FileName := Text;
- OD.SkinData := FDlgSkinData;
- OD.CtrlSkinData := FDlgCtrlSkinData;
- OD.LVHeaderSkinDataName := FLVHeaderSkinDataName;
- if OD.Execute then Text := OD.FileName;
- end;
- procedure TbsSkinSaveFileEdit.Notification;
- begin
- inherited Notification(AComponent, Operation);
- if (Operation = opRemove) and (AComponent = FDlgSkinData) then FDlgSkinData := nil;
- if (Operation = opRemove) and (AComponent = FDlgCtrlSkinData) then FDlgCtrlSkinData := nil;
- end;
- // ======= TbsSkinOpenPictureDialog ====== //
- constructor TbsOpenPictureDlgForm.CreateEx;
- begin
- inherited CreateNew(AOwner);
- SaveMode := ASaveMode;
- KeyPreview := True;
- // BorderStyle := bsDialog;
- Position := poScreenCenter;
- BSF := TbsBusinessSkinForm.Create(Self);
- FromFLV := False;
- FromFTV := False;
- ImagePanel := TbsSkinPanel.Create(Self);
- with ImagePanel do
- begin
- BorderStyle := bvFrame;
- Parent := Self;
- Align := alRight;
- Width := 200;
- end;
- Splitter2 := TbsSkinSplitter.Create(Self);
- with Splitter2 do
- begin
- Parent := Self;
- Align := alRight;
- Width := 10;
- DefaultSize := 10;
- Beveled := False;
- end;
- SBVScrollBar := TbsSkinScrollBar.Create(Self);
- with SBVScrollBar do
- begin
- Kind := sbVertical;
- Parent := ImagePanel;
- Align := alRight;
- DefaultWidth := 19;
- Enabled := False;
- SkinDataName := 'vscrollbar';
- end;
- SBHScrollBar := TbsSkinScrollBar.Create(Self);
- with SBHScrollBar do
- begin
- Parent := ImagePanel;
- Align := alBottom;
- DefaultHeight := 19;
- Enabled := False;
- BothMarkerWidth := 19;
- SkinDataName := 'hscrollbar';
- end;
- ScrollBox := TbsSkinScrollBox.Create(Self);
- with ScrollBox do
- begin
- Align := alClient;
- BorderStyle := bvNone;
- Parent := ImagePanel;
- HScrollBar := SBHScrollBar;
- VScrollBar := SBVScrollBar;
- end;
- Image := TImage.Create(Self);
- with Image do
- begin
- Parent := ScrollBox;
- Left := 0;
- Top := 0;
- end;
- ToolPanel := TbsSkinPanel.Create(Self);
- with ToolPanel do
- begin
- BorderStyle := bvNone;
- Parent := Self;
- Align := alTop;
- DefaultHeight := 25;
- SkinDataName := 'toolpanel';
- OnResize := ToolPanelOnResize;
- end;
- BackToolButton := TbsSkinSpeedButton.Create(Self);
- with BackToolButton do
- begin
- Parent := ToolPanel;
- DefaultHeight := 25;
- DefaultWidth := 75;
- SkinDataName := 'toolbutton';
- Align := alLeft;
- OnClick := BackToolButtonClick;
- NumGlyphs := 1;
- Glyph.LoadFromResourceName(HInstance, 'BS_UP');
- end;
- SortNameToolButton := TbsSkinSpeedButton.Create(Self);
- with SortNameToolButton do
- begin
- Parent := ToolPanel;
- DefaultWidth := 27;
- SkinDataName := 'toolbutton';
- Align := alRight;
- OnClick := SortNameToolButtonClick;
- NumGlyphs := 1;
- Glyph.LoadFromResourceName(HInstance, 'BS_SORTNAME');
- end;
- SortSizeToolButton := TbsSkinSpeedButton.Create(Self);
- with SortSizeToolButton do
- begin
- Parent := ToolPanel;
- DefaultWidth := 27;
- SkinDataName := 'toolbutton';
- Align := alRight;
- OnClick := SortSizeToolButtonClick;
- NumGlyphs := 1;
- Glyph.LoadFromResourceName(HInstance, 'BS_SORTSIZE');
- end;
- SortDateToolButton := TbsSkinSpeedButton.Create(Self);
- with SortDateToolButton do
- begin
- Parent := ToolPanel;
- DefaultWidth := 27;
- SkinDataName := 'toolbutton';
- Align := alRight;
- OnClick := SortDateButtonClick;
- NumGlyphs := 1;
- Glyph.LoadFromResourceName(HInstance, 'BS_SORTDATE');
- end;
- //
- Bevel1 := TbsSkinBevel.Create(Self);
- with Bevel1 do
- begin
- Parent := ToolPanel;
- Width := 27;
- Align := alRight;
- DividerMode := True;
- end;
- //
- ListToolButton := TbsSkinSpeedButton.Create(Self);
- with ListToolButton do
- begin
- Parent := ToolPanel;
- DefaultWidth := 27;
- SkinDataName := 'toolbutton';
- Align := alRight;
- GroupIndex := 1;
- Down := True;
- OnClick := ListToolButtonClick;
- NumGlyphs := 1;
- Glyph.LoadFromResourceName(HInstance, 'BS_LISTSTYLE');
- end;
- SmallIconToolButton := TbsSkinSpeedButton.Create(Self);
- with SmallIconToolButton do
- begin
- Parent := ToolPanel;
- DefaultWidth := 27;
- SkinDataName := 'toolbutton';
- Align := alRight;
- GroupIndex := 1;
- OnClick := SmallIconToolButtonClick;
- NumGlyphs := 1;
- Glyph.LoadFromResourceName(HInstance, 'BS_SMALLICONSTYLE');
- end;
- IconToolButton := TbsSkinSpeedButton.Create(Self);
- with IconToolButton do
- begin
- Parent := ToolPanel;
- DefaultWidth := 27;
- SkinDataName := 'toolbutton';
- Align := alRight;
- GroupIndex := 1;
- OnClick := IconToolButtonClick;
- NumGlyphs := 1;
- Glyph.LoadFromResourceName(HInstance, 'BS_ICONSTYLE');
- end;
- ReportToolButton := TbsSkinSpeedButton.Create(Self);
- with ReportToolButton do
- begin
- Parent := ToolPanel;
- DefaultWidth := 27;
- SkinDataName := 'toolbutton';
- Align := alRight;
- GroupIndex := 1;
- OnClick := ReportToolButtonClick;
- NumGlyphs := 1;
- Glyph.LoadFromResourceName(HInstance, 'BS_REPORTSTYLE');
- end;
- Bevel4 := TbsSkinBevel.Create(Self);
- with Bevel4 do
- begin
- Parent := ToolPanel;
- Width := 27;
- Align := alRight;
- DividerMode := True;
- end;
- StretchButton := TbsSkinSpeedButton.Create(Self);
- with StretchButton do
- begin
- Parent := ToolPanel;
- GroupIndex := 2;
- AllowAllUp := True;
- DefaultHeight := 27;
- DefaultWidth := 27;
- SkinDataName := 'toolbutton';
- Align := alRight;
- OnClick := StretchButtonClick;
- NumGlyphs := 1;
- Glyph.LoadFromResourceName(HInstance, 'BS_STRETCH');
- end;
- Bevel2 := TbsSkinBevel.Create(Self);
- with Bevel2 do
- begin
- Parent := ToolPanel;
- Width := 26;
- Align := alRight;
- DividerMode := True;
- end;
- Bevel3 := TbsSkinBevel.Create(Self);
- with Bevel3 do
- begin
- Parent := ToolPanel;
- Width := 26;
- Align := alLeft;
- DividerMode := True;
- end;
- DriveBox := TbsSkinShellDriveComboBox.Create(Self);
- with DriveBox do
- begin
- Parent := ToolPanel;
- OnChange := DCBChange;
- end;
- BottomPanel := TbsSkinPanel.Create(Self);
- with BottomPanel do
- begin
- Parent := Self;
- Align := alBottom;
- BorderStyle := bvNone;
- Height := 80;
- end;
- Splitter := TbsSkinSplitter.Create(Self);
- with Splitter do
- begin
- Parent := Self;
- Align := alLeft;
- Width := 10;
- DefaultSize := 10;
- Beveled := False;
- end;
- DirTreeViewPanel := TbsSkinExPanel.Create(Self);
- with DirTreeViewPanel do
- begin
- Parent := Self;
- Align := alLeft;
- RollKind := rkRollHorizontal;
- ShowCloseButton := False;
- Width := 150;
- end;
- FileListViewPanel := TbsSkinPanel.Create(Self);
- with FileListViewPanel do
- begin
- Parent := Self;
- Align := alClient;
- BorderStyle := bvFrame;
- end;
- DTVVScrollBar := TbsSkinScrollBar.Create(Self);
- with DTVVScrollBar do
- begin
- Kind := sbVertical;
- Parent := DirTreeViewPanel;
- Align := alRight;
- DefaultWidth := 19;
- Enabled := False;
- SkinDataName := 'vscrollbar';
- end;
- DTVHScrollBar := TbsSkinScrollBar.Create(Self);
- with DTVHScrollBar do
- begin
- Parent := DirTreeViewPanel;
- Align := alBottom;
- DefaultHeight := 19;
- Enabled := False;
- BothMarkerWidth := 19;
- SkinDataName := 'hscrollbar';
- end;
- DirTreeView := TbsSkinDirTreeView.Create(Self);
- with DirTreeView do
- begin
- Parent := DirTreeViewPanel;
- Align := alClient;
- HScrollBar := Self.DTVHScrollBar;
- VScrollBar := Self.DTVVScrollBar;
- OnChange := DTVChange;
- HideSelection := False;
- end;
- FLVHScrollBar := TbsSkinScrollBar.Create(Self);
- with FLVHScrollBar do
- begin
- BothMarkerWidth := 19;
- Parent := FileListViewPanel;
- Align := alBottom;
- DefaultHeight := 19;
- Enabled := False;
- SkinDataName := 'hscrollbar';
- end;
- FLVVScrollBar := TbsSkinScrollBar.Create(Self);
- with FLVVScrollBar do
- begin
- Kind := sbVertical;
- Parent := FileListViewPanel;
- Align := alRight;
- DefaultWidth := 19;
- Enabled := False;
- SkinDataName := 'vscrollbar';
- end;
- FileListView := TbsSkinFileListView.Create(Self);
- with FileListView do
- begin
- Parent := FileListViewPanel;
- ViewStyle := vsList;
- ShowColumnHeaders := True;
- IconOptions.AutoArrange := True;
- GridLines := True;
- Align := alClient;
- HScrollBar := FLVHScrollBar;
- VScrollBar := FLVVScrollBar;
- OnChange := FLVChange;
- OnDblClick := FLVDBLClick;
- HideSelection := False;
- end;
- FileNameEdit := TbsSkinEdit.Create(Self);
- with FileNameEdit do
- begin
- Parent := BottomPanel;
- Top := 10;
- Left := 70;
- Width := 300;
- DefaultHeight := 21;
- OnKeyPress := EditKeyPress;
- end;
- FilterComboBox := TbsSkinFilterComboBox.Create(Self);
- with FilterComboBox do
- begin
- Parent := BottomPanel;
- Top := 45;
- Left := 70;
- Width := 300;
- DefaultHeight := 21;
- OnChange := FCBChange;
- end;
- OpenButton := TbsSkinButton.Create(Self);
- with OpenButton do
- begin
- if SaveMode
- then
- Caption := '&Save'
- else
- Caption := '&Open';
- CanFocused := True;
- Left := 390;
- Top := 10;
- Width := 70;
- DefaultHeight := 25;
- Parent := BottomPanel;
- OnClick := OpenButtonClick;
- end;
- CancelButton := TbsSkinButton.Create(Self);
- with CancelButton do
- begin
- Caption := 'Cancel';
- CanFocused := True;
- Left := 390;
- Top := 45;
- Width := 70;
- DefaultHeight := 25;
- Parent := BottomPanel;
- ModalResult := mrCancel;
- Cancel := True;
- end;
- OpenFileLabel := TbsSkinStdLabel.Create(Self);
- with OpenFileLabel do
- begin
- Caption := 'File name:';
- Left := 10;
- Top := 10;
- AutoSize := True;
- Parent := BottomPanel;
- end;
- FileTypeLabel := TbsSkinStdLabel.Create(Self);
- with FileTypeLabel do
- begin
- Caption := 'File type:';
- Left := 10;
- Top := 45;
- AutoSize := True;
- Parent := BottomPanel;
- end;
- ActiveControl := FileNameEdit;
- end;
- procedure TbsOpenPictureDlgForm.SortNameToolButtonClick(Sender: TObject);
- begin
- FileListView.ColumnClick(Sender, FileListView.Columns[0]);
- end;
- procedure TbsOpenPictureDlgForm.SortSizeToolButtonClick(Sender: TObject);
- begin
- FileListView.ColumnClick(Sender, FileListView.Columns[1]);
- end;
- procedure TbsOpenPictureDlgForm.SortDateButtonClick(Sender: TObject);
- begin
- FileListView.ColumnClick(Sender, FileListView.Columns[3]);
- end;
- procedure TbsOpenPictureDlgForm.ReportToolButtonClick(Sender: TObject);
- begin
- FileListView.ViewStyle := vsReport;
- FileListView.UpdateScrollBars;
- end;
- procedure TbsOpenPictureDlgForm.BackToolButtonClick(Sender: TObject);
- begin
- FileListView.OneLevelUp;
- FileListView.UpdateScrollBars;
- end;
- procedure TbsOpenPictureDlgForm.StretchButtonClick(Sender: TObject);
- begin
- if StretchButton.Down
- then
- begin
- Image.Visible := False;
- Image.Stretch := True;
- Image.Align := alClient;
- Image.Visible := True;
- end
- else
- begin
- Image.Visible := False;
- Image.Align := alNone;
- Image.Width := Image.Picture.Width;
- Image.Height := Image.Picture.Height;
- Image.Stretch := False;
- Image.Visible := True;
- end;
- end;
- procedure TbsOpenPictureDlgForm.ListToolButtonClick(Sender: TObject);
- begin
- FileListView.ViewStyle := vsList;
- FileListView.UpdateScrollBars;
- end;
- procedure TbsOpenPictureDlgForm.SmallIconToolButtonClick(Sender: TObject);
- begin
- FileListView.ViewStyle := vsSmallIcon;
- FileListView.UpdateScrollBars;
- end;
- procedure TbsOpenPictureDlgForm.IconToolButtonClick(Sender: TObject);
- begin
- FileListView.ViewStyle := vsIcon;
- end;
- procedure TbsOpenPictureDlgForm.EditKeyPress;
- var
- FileName: String;
- begin
- inherited;
- if Key = #13
- then
- begin
- if Pos('*', FileNameEdit.Text) <> 0
- then
- FileListView.Mask := FileNameEdit.Text
- else
- begin
- FileName := Self.FileListView.Directory + FileNameEdit.Text;
- if FileExists(FileName)
- then
- OpenButtonClick(Sender)
- else
- if DirectoryExists(FileNameEdit.Text)
- then
- FileListView.Directory := FileNameEdit.Text;
- end;
- end;
- end;
- procedure TbsOpenPictureDlgForm.OpenButtonClick;
- var
- S: String;
- begin
- if FileNameEdit.Text = '' then Exit;
- if SaveMode
- then
- begin
- if FileNameEdit.Text = '' then Exit;
- S := Self.FileListView.Directory + FileNameEdit.Text;
- if (Pos('*', S) = 0)
- then
- begin
- FileName := Self.FileListView.Directory + FileNameEdit.Text;
- ModalResult := mrOk;
- end;
- end
- else
- begin
- FileName := Self.FileListView.Directory + FileNameEdit.Text;
- if FileExists(FileName) then ModalResult := mrOk else FileName := '';
- end;
- end;
- procedure TbsOpenPictureDlgForm.ToolPanelOnResize;
- begin
- if (DriveBox <> nil) and (Bevel2 <> nil) and (Bevel3 <> nil)
- then
- DriveBox.SetBounds(Bevel3.left + Bevel3.Width,
- ToolPanel.Height div 2 - DriveBox.Height div 2,
- Bevel2.Left - Bevel3.Left - Bevel3.Width,
- DriveBox.Height);
- end;
- procedure TbsOpenPictureDlgForm.DCBChange(Sender: TObject);
- begin
- FromDCB := True;
- if not FromFLV and not FromFTV and (DirTreeView <> nil)
- then DirTreeView.Directory := DriveBox.Drive + ':';
- FromDCB := False;
- end;
- procedure TbsOpenPictureDlgForm.FLVChange;
- var
- OldPosition: Integer;
- begin
- FromFLV := True;
- if (not FromFTV) and (DirTreeView.FSelectedPath <> FileListView.Directory)
- then
- begin
- DirTreeView.Directory := FileListView.Directory;
- DirTreeViewPanel.Caption := DirTreeView.Selected.Text;
- end;
- if FileListView.Selected <> nil
- then
- if FileListView.IsFile(FileListView.Selected)
- then
- begin
- FileNameEdit.Text := FileListView.Selected.Caption;
- try
- Image.Picture.LoadFromFile(Self.FileListView.Directory + FileNameEdit.Text);
- finally
- if not Image.Stretch
- then
- begin
- Image.Width := Image.Picture.Width;
- Image.Height := Image.Picture.Height;
- end;
- end;
- end
- else
- FileNameEdit.Text := '';
- FromFLV := False;
- end;
- procedure TbsOpenPictureDlgForm.FLVDBLClick(Sender: TObject);
- begin
- if (FileListView.Selected <> nil) and
- (FileListView.Selected.SubItems[5] = 'file')
- then
- begin
- FileNameEdit.Text := FileListView.Selected.Caption;
- FileName := Self.FileListView.Directory + FileNameEdit.Text;
- ModalResult := mrOk;
- end;
- end;
- procedure TbsOpenPictureDlgForm.DTVChange;
- begin
- FromFTV := True;
- if not FromFLV
- then
- begin
- FileListView.Directory := DirTreeView.GetPathFromNode(Node);
- DirTreeViewPanel.Caption := DirTreeView.Selected.Text;
- end;
- if not FromDCB and (DriveBox <> nil) and (DriveBox.Drives.Count > 0)
- and (DirTreeView.Directory <> '')
- then
- DriveBox.Drive := DirTreeView.Directory[1];
- FromFTV := False;
- end;
- procedure TbsOpenPictureDlgForm.FCBChange(Sender: TObject);
- begin
- FileListView.Mask := FilterComboBox.Mask;
- end;
- constructor TbsSkinOpenPictureDialog.Create(AOwner: TComponent);
- begin
- inherited Create(AOwner);
- DialogWidth := 0;
- DialogHeight := 0;
- DialogStretch := False;
- FLVHeaderSkinDataName := 'resizebutton';
- FAlphaBlend := False;
- FAlphaBlendAnimation := False;
- FAlphaBlendValue := 200;
- FSaveMode := False;
- FTitle := 'Open picture';
- FDefaultFont := TFont.Create;
- with FDefaultFont do
- begin
- Name := 'Arial';
- Style := [];
- Height := 14;
- end;
- FInitialDir := '';
- FFilter := 'All (*.bmp;*.ico;*.emf;*.wmf)|*.bmp;*.ico;*.emf;*.wmf|Bitmaps (*.bmp)|*.bmp|Icons (*.ico)|*.ico|Enhanced Metafiles (*.emf)|*.emf|Metafiles (*.wmf)|*.wmf';
- FFilterIndex := 0;
- FFileName := '';
- TreePanelWidth := 150;
- ImagePanelWidth := 200;
- ListViewStyle := vsList;
- end;
- destructor TbsSkinOpenPictureDialog.Destroy;
- begin
- FDefaultFont.Free;
- inherited Destroy;
- end;
- procedure TbsSkinOpenPictureDialog.SetDefaultFont;
- begin
- FDefaultFont.Assign(Value);
- end;
- procedure TbsSkinOpenPictureDialog.Notification;
- begin
- inherited Notification(AComponent, Operation);
- if (Operation = opRemove) and (AComponent = FSD) then FSD := nil;
- if (Operation = opRemove) and (AComponent = FCtrlFSD) then FCtrlFSD := nil;
- end;
- function TbsSkinOpenPictureDialog.GetTitle: string;
- begin
- Result := FTitle;
- end;
- procedure TbsSkinOpenPictureDialog.SetTitle(const Value: string);
- begin
- FTitle := Value;
- end;
- procedure TbsSkinOpenPictureDialog.Change;
- begin
- if Assigned(FOnChange) then FOnChange(Self);
- end;
- function TbsSkinOpenPictureDialog.Execute: Boolean;
- var
- i, FW, FH: Integer;
- Path: String;
- begin
- FDlgFrm := TbsOpenPictureDlgForm.CreateEx(Application, FSaveMode);
- with FDlgFrm do
- try
- Caption := Self.Title;
- BSF.BorderIcons := [];
- BSF.SkinData := FSD;
- BSF.MenusSkinData := CtrlSkinData;
- BSF.AlphaBlend := AlphaBlend;
- BSF.AlphaBlendAnimation := AlphaBlendAnimation;
- BSF.AlphaBlendValue := AlphaBlendValue;
- DirTreeView.SkinData := FCtrlFSD;
- DirTreeView.Color := clWindow;
- DirTreeViewPanel.Width := TreePanelWidth;
- ImagePanel.Width := ImagePanelWidth;
- DirTreeViewPanel.RollState := TreePanelRollState;
- case ListViewStyle of
- vsList: ListToolButton.Down := True;
- vsReport: ReportToolButton.Down := True;
- vsIcon: IconToolButton.Down := True;
- vsSmallIcon: SmallIconToolButton.Down := True;
- end;
- FileListView.ViewStyle := ListViewStyle;
- if (FFileName <> '') and (ExtractFilePath(FFileName) <> '')
- then
- begin
- Path := ExtractFilePath(FFileName);
- FileListView.Directory := Path;
- FileNameEdit.Text := ExtractFileName(FFileName);
- for i := 0 to FileListView.Items.Count - 1 do
- if FileListView.Items[i].Caption = FileNameEdit.Text
- then
- begin
- FileListView.Selected := FileListView.Items[i];
- Break;
- end;
- end
- else
- begin
- if FInitialDir = ''
- then
- FileListView.Directory := ExtractFilePath(Application.ExeName)
- else
- FileListView.Directory := FInitialDir;
- FileNameEdit.Text := FFileName;
- end;
- FromFLV := True;
- DriveBox.Drive := FileListView.Directory[1];
- FromFLV := False;
- FileListView.HeaderSkinDataName := FLVHeaderSkinDataName;
- FileListView.SkinData := FCtrlFSD;
- FilterComboBox.Filter := Self.Filter;
- FilterComboBox.ItemIndex := FFilterIndex;
- //
- ImagePanel.SkinData := FCtrlFSD;
- ScrollBox.SkinData := FCtrlFSD;
- SBHScrollBar.SkinData := FCtrlFSD;
- SBVScrollBar.SkinData := FCtrlFSD;
- StretchButton.SkinData := FCtrlFSD;
- //
- DirTreeViewPanel.SkinData := FCtrlFSD;
- FileListViewPanel.SkinData := FCtrlFSD;
- BottomPanel.SkinData := FCtrlFSD;
- ToolPanel.SkinData := FCtrlFSD;
- Bevel1.SkinData := FCtrlFSD;
- Bevel2.SkinData := FCtrlFSD;
- Bevel3.SkinData := FCtrlFSD;
- DriveBox.SkinData := FCtrlFSD;
- Bevel4.SkinData := FCtrlFSD;
- BackToolButton.SkinData := FCtrlFSD;
- ListToolButton.SkinData := FCtrlFSD;
- ReportToolButton.SkinData := FCtrlFSD;
- IconToolButton.SkinData := FCtrlFSD;
- SmallIconToolButton.SkinData := FCtrlFSD;
- SortNameToolButton.SkinData := FCtrlFSD;
- SortSizeToolButton.SkinData := FCtrlFSD;
- SortDateToolButton.SkinData := FCtrlFSD;
- //
- Splitter.SkinData := FCtrlFSD;
- Splitter2.SkinData := FCtrlFSD;
- DTVHScrollBar.SkinData := FCtrlFSD;
- DTVVScrollBar.SkinData := FCtrlFSD;
- FLVHScrollBar.SkinData := FCtrlFSD;
- FLVVScrollBar.SkinData := FCtrlFSD;
- FileNameEdit.SkinData := FCtrlFSD;
- FilterComboBox.SkinData := FCtrlFSD;
- OpenButton.SkinData := FCtrlFSD;
- CancelButton.SkinData := FCtrlFSD;
- OpenFileLabel.SkinData := FCtrlFSD;
- FileTypeLabel.SkinData := FCtrlFSD;
- //
- if (DialogWidth <> 0)
- then
- begin
- FW := DialogWidth;
- FH := DialogHeight;
- end
- else
- begin
- FW := 600;
- FH := 300;
- end;
- if (SkinData <> nil) and not SkinData.Empty
- then
- begin
- if FW < BSF.GetMinWidth then FW := BSF.GetMinWidth;
- if FH < BSF.GetMinHeight then FH := BSF.GetMinHeight;
- end;
- ClientWidth := FW;
- ClientHeight := FH;
- StretchButton.Down := DialogStretch;
- if StretchButton.Down
- then
- begin
- Image.Visible := False;
- ScrollBox.UpDateScrollRange;
- Image.Stretch := True;
- Image.Align := alClient;
- Image.Visible := True;
- end;
- Result := (ShowModal = mrOk);
- DialogStretch := StretchButton.Down;
- ImagePanelWidth := ImagePanel.Width;
- if DirTreeViewPanel.RollState
- then
- TreePanelWidth := DirTreeViewPanel.RealWidth
- else
- TreePanelWidth := DirTreeViewPanel.Width;
- TreePanelRollState := DirTreeViewPanel.RollState;
- ListViewStyle := FileListView.ViewStyle;
- DialogWidth := ClientWidth;
- DialogHeight := ClientHeight;
- if Result
- then
- begin
- Self.FFileName := FDlgFrm.FileName;
- Change;
- end;
- finally
- Free;
- FDlgFrm := nil;
- end;
- end;
- constructor TbsSkinSavePictureDialog.Create(AOwner: TComponent);
- begin
- inherited;
- FTitle := 'Save picture';
- FSaveMode := True;
- end;
- end.