spSkinShellCtrls.pas
上传用户:hylc_2004
上传日期:2014-01-23
资源大小:46800k
文件大小:105k
源码类别:
Delphi控件源码
开发平台:
Delphi
- {*******************************************************************}
- { }
- { Almediadev Visual Component Library }
- { DynamicSkinForm }
- { Version 5.60 }
- { }
- { Copyright (c) 2000-2003 Almediadev }
- { ALL RIGHTS RESERVED }
- { }
- { Home: http://www.almdev.com }
- { Support: support@almdev.com }
- { }
- {*******************************************************************}
- unit spSkinShellCtrls;
- {$WARNINGS OFF}
- {$HINTS OFF}
- interface
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
- Dialogs, StdCtrls, ExtCtrls, ComCtrls, CommCtrl, ShellAPI, ShlObj, ActiveX,
- Menus, ImgList, SkinCtrls, DynamicSkinForm, SkinData, SkinBoxCtrls,
- spFileCtrl, spMessages;
- 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;
- TspSkinFileListView = class(TspSkinListView)
- private
- FSkinMessage: TspSkinMessage;
- 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;
- function GetFiles: TStringList;
- 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;
- procedure Notification(AComponent: TComponent; Operation: TOperation); override;
- 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;
- property Files: TStringList read GetFiles;
- published
- property SkinMessage: TspSkinMessage
- read FSkinMessage write FSkinMessage;
- 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;
- TspSkinDirTreeView = class(TspSkinCustomTreeView)
- private
- FSkinMessage: TspSkinMessage;
- FPreviousPath: string;
- FSelectedPath: string;
- TreeViewPath: string;
- OldTreeViewPath: 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;
- procedure Notification(AComponent: TComponent; Operation: TOperation); override;
- public
- constructor create(AOwner: TComponent); override;
- destructor destroy; override;
- procedure ChangeSkinData; override;
- property InitialDir: string read FInitialDir Write SetInitialDir;
- procedure ReLoad;
- procedure OpenPath(dPath: string);
- property Images;
- property Items;
- property Directory: String read GetDirectory write SetDirectory;
- published
- property SkinMessage: TspSkinMessage
- read FSkinMessage write FSkinMessage;
- 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;
- TspSkinShellDriveComboBox = class(TspSkinComboBox)
- 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 }
- TspSelDirDlgForm = class(TForm)
- public
- DSF: TspDynamicSkinForm;
- DirTreeViewPanel, BottomPanel: TspSkinPanel;
- DirTreeView: TspSkinDirTreeView;
- VScrollBar, HScrollBar: TspSkinScrollBar;
- OkButton, CancelButton: TspSkinButton;
- constructor Create(AOwner: TComponent); override;
- end;
- TspSkinSelectDirectoryDialog = class(TComponent)
- private
- FSkinMessage: TspSkinMessage;
- FSD: TspSkinData;
- FCtrlFSD: TspSkinData;
- FDefaultFont: TFont;
- FTitle: String;
- FDlgFrm: TspSelDirDlgForm;
- 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 SkinMessage: TspSkinMessage
- read FSkinMessage write FSkinMessage;
- property AlphaBlend: Boolean read FAlphaBlend write FAlphaBlend;
- property AlphaBlendValue: Byte read FAlphaBlendValue write FAlphaBlendValue;
- property AlphaBlendAnimation: Boolean
- read FAlphaBlendAnimation write FAlphaBlendAnimation;
- property SkinData: TspSkinData read FSD write FSD;
- property CtrlSkinData: TspSkinData 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;
- TspOpenDlgForm = class(TForm)
- private
- FromFLV: Boolean;
- FromFTV: Boolean;
- FromDCB: Boolean;
- SaveMode: Boolean;
- public
- FileName: String;
- DSF: TspDynamicSkinForm;
- DirTreeViewPanel: TspSkinExPanel;
- FileListViewPanel,
- BottomPanel: TspSkinPanel;
- Splitter: TspSkinSplitter;
- DTVHScrollBar, DTVVScrollBar,
- FLVHScrollBar, FLVVScrollBar: TspSkinScrollBar;
- DirTreeView: TspSkinDirTreeView;
- FileListView: TspSkinFileListView;
- FileNameEdit: TspSkinEdit;
- FilterComboBox: TspSkinFilterComboBox;
- OpenButton, CancelButton: TspSkinButton;
- OpenFileLabel, FileTypeLabel: TspSkinStdLabel;
- ToolPanel: TspSkinPanel;
- ListToolButton, ReportToolButton,
- IconToolButton, SmallIconToolButton, BackToolButton: TspSkinSpeedButton;
- Bevel1, Bevel2, Bevel3: TspSkinBevel;
- DriveBox: TspSkinShellDriveComboBox;
- MyDocToolButton: TspSkinSpeedButton;
- 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 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 MyDocToolButtonClick(Sender: TObject);
- end;
- TspSkinOpenDialog = class(TComponent)
- private
- FFiles: TStringList;
- FMultiSelection: Boolean;
- FSkinMessage: TspSkinMessage;
- FSD: TspSkinData;
- FCtrlFSD: TspSkinData;
- FLVHeaderSkinDataName: String;
- FDefaultFont: TFont;
- FTitle: String;
- FDlgFrm: TspOpenDlgForm;
- 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;
- property Files: TStringList read FFiles;
- constructor Create(AOwner: TComponent); override;
- destructor Destroy; override;
- function Execute: Boolean;
- published
- property MultiSelection: Boolean read FMultiSelection write FMultiSelection;
- property SkinMessage: TspSkinMessage
- read FSkinMessage write FSkinMessage;
- 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: TspSkinData read FSD write FSD;
- property CtrlSkinData: TspSkinData 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;
- TspSkinSaveDialog = class(TspSkinOpenDialog)
- public
- constructor Create(AOwner: TComponent); override;
- end;
- TspSkinDirectoryEdit = class(TspSkinEdit)
- protected
- FDlgSkinData: TspSkinData;
- FDlgCtrlSkinData: TspSkinData;
- SD: TspSkinSelectDirectoryDialog;
- procedure Notification(AComponent: TComponent; Operation: TOperation); override;
- public
- constructor Create(AOwner: TComponent); override;
- destructor Destroy; override;
- procedure ButtonClick(Sender: TObject);
- published
- property DlgSkinData: TspSkinData read FDlgSkinData write FDlgSkinData;
- property DlgCtrlSkinData: TspSkinData read FDlgCtrlSkinData write FDlgCtrlSkinData;
- end;
- TspSkinFileEdit = class(TspSkinEdit)
- protected
- FDlgSkinData: TspSkinData;
- FDlgCtrlSkinData: TspSkinData;
- OD: TspSkinOpenDialog;
- 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: TspSkinData read FDlgSkinData write FDlgSkinData;
- property DlgCtrlSkinData: TspSkinData read FDlgCtrlSkinData write FDlgCtrlSkinData;
- property LVHeaderSkinDataName: String
- read FLVHeaderSkinDataName write FLVHeaderSkinDataName;
- end;
- TspSkinSaveFileEdit = class(TspSkinEdit)
- protected
- FDlgSkinData: TspSkinData;
- FDlgCtrlSkinData: TspSkinData;
- OD: TspSkinSaveDialog;
- 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: TspSkinData read FDlgSkinData write FDlgSkinData;
- property DlgCtrlSkinData: TspSkinData read FDlgCtrlSkinData write FDlgCtrlSkinData;
- property LVHeaderSkinDataName: String
- read FLVHeaderSkinDataName write FLVHeaderSkinDataName;
- end;
- TspOpenPictureDlgForm = class(TForm)
- private
- FromFLV: Boolean;
- FromFTV: Boolean;
- FromDCB: Boolean;
- SaveMode: Boolean;
- public
- FileName: String;
- DSF: TspDynamicSkinForm;
- DirTreeViewPanel: TspSkinExPanel;
- FileListViewPanel,
- BottomPanel: TspSkinPanel;
- Splitter, Splitter2: TspSkinSplitter;
- DTVHScrollBar, DTVVScrollBar,
- FLVHScrollBar, FLVVScrollBar: TspSkinScrollBar;
- DirTreeView: TspSkinDirTreeView;
- FileListView: TspSkinFileListView;
- FileNameEdit: TspSkinEdit;
- FilterComboBox: TspSkinFilterComboBox;
- OpenButton, CancelButton: TspSkinButton;
- OpenFileLabel, FileTypeLabel: TspSkinStdLabel;
- ToolPanel: TspSkinPanel;
- ListToolButton, ReportToolButton,
- IconToolButton, SmallIconToolButton, BackToolButton: TspSkinSpeedButton;
- Bevel1, Bevel2, Bevel3: TspSkinBevel;
- DriveBox: TspSkinShellDriveComboBox;
- MyDocToolButton: TspSkinSpeedButton;
- //
- ImagePanel: TspSkinPanel;
- Image: TImage;
- ScrollBox: TspSkinScrollBox;
- SBVScrollBar, SBHScrollBar: TspSkinScrollBar;
- Bevel4: TspSkinBevel;
- StretchButton: TspSkinSpeedButton;
- 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 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 MyDocToolButtonClick(Sender: TObject);
- end;
- TspSkinOpenPictureDialog = class(TComponent)
- private
- FFiles: TStringList;
- FMultiSelection: Boolean;
- FSkinMessage: TspSkinMessage;
- FLVHeaderSkinDataName: String;
- FAlphaBlend: Boolean;
- FAlphaBlendValue: Byte;
- FAlphaBlendAnimation: Boolean;
- FSD: TspSkinData;
- FCtrlFSD: TspSkinData;
- FDefaultFont: TFont;
- FTitle: String;
- FDlgFrm: TspOpenPictureDlgForm;
- 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;
- property Files: TStringList read FFiles;
- constructor Create(AOwner: TComponent); override;
- destructor Destroy; override;
- function Execute: Boolean;
- published
- property MultiSelection: Boolean read FMultiSelection write FMultiSelection;
- property SkinMessage: TspSkinMessage
- read FSkinMessage write FSkinMessage;
- 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: TspSkinData read FSD write FSD;
- property CtrlSkinData: TspSkinData 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;
- TspSkinSavePictureDialog = class(TspSkinOpenPictureDialog)
- public
- constructor Create(AOwner: TComponent); override;
- end;
- function GetPersonalRoot(H: THandle): String;
- implementation
- Uses spConst;
- {$R spSkinShellCtrls}
- 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 GetPersonalRoot(H: THandle): String;
- const
- CSIDL_PERSONAL = $0005;
- var
- Root: PItemIDList;
- Path: LPSTR;
- begin
- Path := StrAlloc(MAX_PATH);
- SHGetSpecialFolderLocation(H, CSIDL_PERSONAL, Root);
- if SHGetPathFromIDList(Root, Path)
- then
- Result := Path
- else
- Result := '';
- StrDispose(Path);
- end;
- 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 TspSkinFileListView.Create(AOwner: TComponent);
- begin
- inherited Create(AOwner);
- ReadOnly := True;
- fselectedfiles := TStringlist.create;
- Createimages;
- FMask := DefaultMask;
- FSortForward := True;
- FSortColumn := 0;
- OnCompare:=CompareFiles;
- OnColumnClick:=ColumnClick;
- if csDesigning in ComponentState then fdirectory := 'c:';
- FSkinMessage := nil;
- end;
- procedure TspSkinFileListView.Notification;
- begin
- inherited Notification(AComponent, Operation);
- if (Operation = opRemove) and (AComponent = FSkinMessage)
- then
- FSkinMessage := nil;
- end;
- destructor TspSkinFileListView.Destroy;
- begin
- LImageList.Free;
- SImageList.Free;
- fSelectedFiles.Free;
- inherited Destroy;
- end;
- function TspSkinFileListView.IsFile;
- begin
- Result := Item.SubItems[5]='file';
- end;
- function TspSkinFileListView.GetSelectedNum: Integer;
- begin
- Result:=SelCount;
- if Result=0 then
- Result:=Items.Count;
- end;
- function TspSkinFileListView.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 TspSkinFileListView.GetDirectory: String;
- begin
- Result:=FDirectory;
- end;
- procedure TspSkinFileListView.SetDirectory(NewDir: String);
- function IsDrive(S: String): Boolean;
- var
- D: Char;
- ErrorMode: Word;
- begin
- if (Length(S) = 3) and (Pos(':', S) <> 0)
- then
- begin
- D := S[1];
- if D in ['a'..'z'] then Dec(D, $20);
- ErrorMode := SetErrorMode(SEM_FailCriticalErrors);
- try
- if DiskSize(Ord(D) - $40) = -1
- then
- begin
- MessageBeep(MB_IconHand);
- if FSkinMessage = nil
- then
- MessageDlg(SP_NODISKINDRIVE, mtWarning, [mbOK], 0)
- else
- SkinMessage.MessageDlg(SP_NODISKINDRIVE,
- mtWarning, [mbOK], 0);
- Result := False
- end
- else
- Result := True;
- finally
- SetErrorMode(ErrorMode);
- end;
- end
- else
- Result := True;
- end;
- begin
- if AnsiCompareText(NewDir,FDirectory) = 0 then Exit;
- if (UpperCase(NewDir)='DRIVES')
- then
- begin
- FDirectory:=NewDir;
- UpdateFileList;
- end
- else
- begin
- if not IsDrive(NewDir) then Exit;
- if not DirectoryExists(NewDir) then Exit;
- NewDir := IncludeTrailingBackslash(NewDir);
- SetCurrentDir(NewDir);
- FDirectory:=NewDir;
- UpdateFileList;
- end;
- end;
- procedure TspSkinFileListView.SetMask(const NewMasks: String);
- begin
- if FMask<>NewMasks then begin
- FMask:=NewMasks;
- UpdateFileList;
- end;
- end;
- function TspSkinFileListView.GetFileName: String;
- begin
- Result:=FFileName;
- end;
- procedure TspSkinFileListView.SetFileName(NewFile: String);
- begin
- if FFileName <> NewFile then FFileName:=NewFile;
- end;
- procedure TspSkinFileListView.SetFileType(NewFileType: TFileType);
- begin
- if NewFileType<>FFileType then begin
- FFileType:=NewFileType;
- UpdateFileList;
- end;
- end;
- procedure TspSkinFileListView.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 TspSkinFileListView.CreateWnd;
- begin
- inherited;
- if Columns.Count=0 then begin
- with Columns.Add do begin
- Caption := SP_FLV_NAME;
- Width := 200;
- end;
- with Columns.Add do begin
- Caption := SP_FLV_SIZE;
- Width := 70;
- Alignment := taRightJustify;
- end;
- with Columns.Add do begin
- Caption := SP_FLV_TYPE;
- Width := 90;
- end;
- with Columns.Add do begin
- Caption := SP_FLV_MODIFIED;
- Width := 100;
- end;
- with Columns.Add do begin
- Caption := SP_FLV_ATTRIBUTES;
- width := 60;
- end;
- UpdateFileList;
- end;
- end;
- procedure TspSkinFileListView.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 TspSkinFileListView.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 TspSkinFileListView.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 TspSkinFileListView.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:=SP_FLV_TYPE;
- Column[1].Width:=100;
- Column[1].Alignment:=taLeftJustify;
- Column[2].Caption:=SP_FLV_DISKSIZE;
- Column[2].Width:=100;
- Column[2].Alignment:=taRightJustify;
- Column[3].Caption:=SP_FLV_FREESPACE;
- Column[3].Width:=100;
- Column[3].Alignment:=taRightJustify;
- AddDrives;
- end else begin
- Column[1].Caption:=SP_FLV_SIZE;
- Column[1].Width:=70;
- Column[1].Alignment:=taRightJustify;
- Column[2].Caption:=SP_FLV_TYPE;
- Column[2].Width:=150;
- Column[2].Alignment:=taLeftJustify;
- Column[3].Caption:=SP_FLV_ATTRIBUTES;
- 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 TspSkinFileListView.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 TspSkinFileListView.AddFile(FileMask: String; Attr: DWord): Boolean;
- var
- ShInfo: TSHFileInfo;
- S, 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))then begin
- CurPath:=IncludeTrailingBackslash(FDirectory);
- FName:=FI.Name;
- S := ExtractFileExt(FileMask);
- if (Pos ('*', S) = 0) and (Pos ('?', S) = 0) and
- not ((FI.Attr and FILE_ATTRIBUTE_DIRECTORY)=FILE_ATTRIBUTE_DIRECTORY) and
- (UpperCase(ExtractFileExt(FI.Name)) <> UpperCase(ExtractFileExt(FileMask)))
- then
- Continue;
- 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 TspSkinFileListView.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 TspSkinFileListView.Click;
- begin
- if (Selected <> nil) and (Selected.SubItems[5] = 'file')
- then
- SetFileName(Selected.SubItems[4])
- else
- SetFileName('');
- inherited;
- end;
- procedure TspSkinFileListView.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 TspSkinFileListView.WMRButtonDown(var Message: TWMRButtonDown);
- begin
- DoMouseDown(Message, mbRight, []);
- end;
- procedure TspSkinFileListView.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 TspSkinFileListView.GetFiles: TStringList;
- begin
- GetSelectedFilenames;
- Result := FSelectedFiles;
- end;
- function TspSkinFileListView.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(Items[i].SubItems[4]);
- result:=result+Items[i].SubItems[4]+';';
- end;
- Result:=copy(result,1,length(result)-1);
- end;
- function TspSkinFileListView.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 TspSkinFileListView.GetDiskCap: Int64;
- begin
- Result:=GetDiskInfo(Copy(FDirectory,1,1)+':').Capacity;
- end;
- function TspSkinFileListView.GetDiskFree: Int64;
- begin
- Result:=GetDiskInfo(Copy(FDirectory,1,1)+':').FreeSpace;
- end;
- function TspSkinFileListView.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 TspSkinFileListView.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;
- { ================================TspSkinDirTreeView ==============================}
- const
- InvalidDOSChars = '*?/="<>|:,;+^';
- 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; SM: TspSkinMessage): Boolean;
- var
- ErrorMode: word;
- begin
- if Drive in ['a'..'z'] then
- Dec(Drive, $20);
- if not (Drive in ['A'..'Z']) then
- if SM = nil
- then
- MessageDlg(SP_NOVALIDDRIVEID, mtError, [mbOK], 0)
- else
- SM.MessageDlg(SP_NOVALIDDRIVEID, mtError, [mbOK], 0);
- ErrorMode := SetErrorMode(SEM_FailCriticalErrors);
- try
- if DiskSize(Ord(Drive) - $40) = -1 then
- begin
- if ShowMsg > 0 then
- begin
- MessageBeep(MB_IconHand);
- if SM = nil
- then
- MessageDlg(SP_NODISKINDRIVE, mtWarning, [mbOK], 0)
- else
- SM.MessageDlg(SP_NODISKINDRIVE,
- 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 TspSkinDirTreeView.CreateWnd;
- begin
- inherited CreateWnd;
- if not (csLoading in ComponentState)
- then
- begin
- ReLoad;
- if Items.GetFirstNode <> nil then
- Items.GetFirstNode.Expand(False);
- end;
- end;
- constructor TspSkinDirTreeView.Create;
- var
- sfi: TShFileInfo;
- hImgLst: Uint;
- begin
- inherited Create(AOwner);
- OldTreeViewPath := '';
- 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;
- FSkinMessage := nil;
- end;
- destructor TspSkinDirTreeView.Destroy;
- var
- i: integer;
- begin
- for i := Items.Count - 1 downto 0 do
- Items[i].Free;
- Images.Free;
- inherited Destroy;
- end;
- procedure TspSkinDirTreeView.ChangeSkinData;
- begin
- inherited;
- IMages.BkColor := Self.Color;
- end;
- procedure TspSkinDirTreeView.Notification;
- begin
- inherited Notification(AComponent, Operation);
- if (Operation = opRemove) and (AComponent = FSkinMessage)
- then
- FSkinMessage := nil;
- end;
- function TspSkinDirTreeView.GetDirectory: String;
- begin
- Result := GetPathFromNode(Self.Selected);
- end;
- procedure TspSkinDirTreeView.SetDirectory(Value: String);
- begin
- OpenPath(Value);
- end;
- procedure TspSkinDirTreeView.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 TspSkinDirTreeView.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 TspSkinDirTreeView.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 TspSkinDirTreeView.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
- if (Length(Path) = 3) and (Pos(':', Path) <> 0)
- then
- begin
- if not DiskInDrive(Path[1], 1, FSkinMessage)
- then
- Exit;
- end;
- 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 TspSkinDirTreeView.ReLoad;
- begin
- Items.BeginUpdate;
- Items.Clear;
- LoadRoot;
- LoadDrives;
- Items.EndUpdate;
- end;
- procedure TspSkinDirTreeView.Loaded;
- begin
- inherited Loaded;
- Reload;
- if Items.GetFirstNode <> nil then
- Items.GetFirstNode.Expand(False);
- end;
- procedure TspSkinDirTreeView.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 TspSkinDirTreeView.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, FSkinMessage) then
- begin
- OpenPath(FPreviousPath);
- exit;
- end;
- end;
- FPreviousPath := FSelectedPath;
- end;
- end;
- procedure TspSkinDirTreeView.SetSelectedPath(Value: string);
- begin
- if AnsiCompareText(Value, FSelectedPath) = 0 then
- exit;
- FSelectedPath := Value;
- end;
- procedure TspSkinDirTreeView.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 TspSkinDirTreeView.OpenPath(dPath: string);
- var
- CurNode: TTreeNode;
- count: Integer;
- TempPath: string;
- CurPath: string;
- FullPath: string;
- begin
- if (dPath = '') or (Length(dPath) = 1) then Exit;
- if (Length(dPath) = 3) and (Pos(':', dPath) <> 0) and
- not DiskInDrive(dPath[1], 1, SkinMessage)
- then
- Exit;
- if not DirectoryExists(dPath) then exit;
- dPath := AddSlash(dPath);
- FullPath := dPath;
- Items.BeginUpdate;
- CurNode := Items.GetFirstNode;
- if CurNode.getFirstChild = nil then
- LoadDrives;
- 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 TspSkinDirTreeView.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, FSkinMessage) then
- exit;
- end;
- end;
- if Key=VK_F5 then
- begin
- Reload;
- OpenPath(FSelectedPath);
- end;
- end;
- function TspSkinDirTreeView.GetPathFromNode(Node: TTreeNode): string;
- begin
- Result := '';
- if Node = nil then exit;
- if Assigned(Node) then
- begin
- MakePath(Node);
- Result := TreeViewPath;
- end;
- end;
- function TspSkinDirTreeView.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 TspSkinDirTreeView.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;
- constructor TspSkinShellDriveComboBox.Create(AOwner: TComponent);
- begin
- inherited Create(AOwner);
- Style := spcbFixedStyle;
- 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 TspSkinShellDriveComboBox.Destroy;
- begin
- Drives.Free;
- Images.Free;
- inherited Destroy;
- end;
- procedure TspSkinShellDriveComboBox.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 TspSkinShellDriveComboBox.CreateWnd;
- begin
- inherited CreateWnd;
- BuildList;
- end;
- procedure TspSkinShellDriveComboBox.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 TspSkinShellDriveComboBox.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 TspSkinShellDriveComboBox.Change;
- begin
- if ItemIndex <> -1 then DriveItemIndex := ItemIndex;
- SetDrive(Drives[DriveItemIndex][1]);
- if Assigned(FOnChange) then FOnChange(Self);
- end;
- procedure TspSkinShellDriveComboBox.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 TspSelDirDlgForm.Create(AOwner: TComponent);
- begin
- inherited CreateNew(AOwner);
- KeyPreview := True;
- Position := poScreenCenter;
- DSF := TspDynamicSkinForm.Create(Self);
- DirTreeViewPanel := TspSkinPanel.Create(Self);
- with DirTreeViewPanel do
- begin
- Parent := Self;
- Align := alClient;
- BorderStyle := bvFrame;
- Height := 200;
- end;
- VScrollBar := TspSkinScrollBar.Create(Self);
- with VScrollBar do
- begin
- Kind := sbVertical;
- Parent := DirTreeViewPanel;
- Align := alRight;
- DefaultWidth := 19;
- Enabled := False;
- SkinDataName := 'vscrollbar';
- end;
- HScrollBar := TspSkinScrollBar.Create(Self);
- with HScrollBar do
- begin
- Parent := DirTreeViewPanel;
- Align := alBottom;
- DefaultHeight := 19;
- Enabled := False;
- BothMarkerWidth := 19;
- SkinDataName := 'hscrollbar';
- end;
- DirTreeView := TspSkinDirTreeView.Create(Self);
- with DirTreeView do
- begin
- Parent := DirTreeViewPanel;
- Align := alClient;
- HScrollBar := Self.HScrollBar;
- VScrollBar := Self.VScrollBar;
- HideSelection := False;
- end;
- BottomPanel := TspSkinPanel.Create(Self);
- with BottomPanel do
- begin
- Parent := Self;
- Align := alBottom;
- BorderStyle := bvNone;
- Height := 50;
- end;
- OkButton := TspSkinButton.Create(Self);
- with OkButton do
- begin
- Default := True;
- Caption := SP_MSG_BTN_OK;
- CanFocused := True;
- Left := 20;
- Top := 15;
- Width := 70;
- DefaultHeight := 25;
- Parent := BottomPanel;
- ModalResult := mrOk;
- end;
- CancelButton := TspSkinButton.Create(Self);
- with CancelButton do
- begin
- Caption := SP_MSG_BTN_CANCEL;
- CanFocused := True;
- Left := 100;
- Top := 15;
- Width := 70;
- DefaultHeight := 25;
- Parent := BottomPanel;
- ModalResult := mrCancel;
- Cancel := True;
- end;
- end;
- constructor TspSkinSelectDirectoryDialog.Create(AOwner: TComponent);
- begin
- inherited Create(AOwner);
- FSkinMessage := nil;
- 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 TspSkinSelectDirectoryDialog.Destroy;
- begin
- FDefaultFont.Free;
- inherited Destroy;
- end;
- procedure TspSkinSelectDirectoryDialog.SetDefaultFont;
- begin
- FDefaultFont.Assign(Value);
- end;
- procedure TspSkinSelectDirectoryDialog.Notification;
- begin
- inherited Notification(AComponent, Operation);
- if (Operation = opRemove) and (AComponent = FSD) then FSD := nil;
- if (Operation = opRemove) and (AComponent = FCtrlFSD) then FCtrlFSD := nil;
- if (Operation = opRemove) and (AComponent = FSkinMessage)
- then
- FSkinMessage := nil;
- end;
- function TspSkinSelectDirectoryDialog.GetTitle: string;
- begin
- Result := FTitle;
- end;
- procedure TspSkinSelectDirectoryDialog.SetTitle(const Value: string);
- begin
- FTitle := Value;
- end;
- procedure TspSkinSelectDirectoryDialog.Change;
- begin
- if Assigned(FOnChange) then FOnChange(Self);
- end;
- function TspSkinSelectDirectoryDialog.Execute: Boolean;
- var
- FW, FH: Integer;
- begin
- FDlgFrm := TspSelDirDlgForm.Create(Application);
- with FDlgFrm do
- try
- Caption := Self.Title;
- DSF.BorderIcons := [];
- DSF.SkinData := FSD;
- DSF.MenusSkinData := CtrlSkinData;
- DSF.AlphaBlend := AlphaBlend;
- DSF.AlphaBlendAnimation := AlphaBlendAnimation;
- DSF.AlphaBlendValue := AlphaBlendValue;
- //
- DirTreeViewPanel.SkinData := FCtrlFSD;
- DirTreeView.DefaultFont := DefaultFont;
- DirTreeView.SkinData := FCtrlFSD;
- DirTreeView.SkinMessage := FSkinMessage;
- 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 < DSF.GetMinWidth then FW := DSF.GetMinWidth;
- if FH < DSF.GetMinHeight then FH := DSF.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 TspOpenDlgForm.CreateEx(AOwner: TComponent; ASaveMode: Boolean);
- begin
- inherited CreateNew(AOwner);
- SaveMode := ASaveMode;
- KeyPreview := True;
- Position := poScreenCenter;
- DSF := TspDynamicSkinForm.Create(Self);
- FromFLV := False;
- FromFTV := False;
- ToolPanel := TspSkinPanel.Create(Self);
- with ToolPanel do
- begin
- BorderStyle := bvNone;
- Parent := Self;
- Align := alTop;
- DefaultHeight := 25;
- SkinDataName := 'toolpanel';
- end;
- BackToolButton := TspSkinSpeedButton.Create(Self);
- with BackToolButton do
- begin
- Parent := ToolPanel;
- DefaultHeight := 25;
- DefaultWidth := 70;
- SkinDataName := 'toolbutton';
- Align := alLeft;
- OnClick := BackToolButtonClick;
- NumGlyphs := 1;
- Glyph.LoadFromResourceName(HInstance, 'SP_UP');
- end;
- MyDocToolButton := TspSkinSpeedButton.Create(Self);
- with MyDocToolButton do
- begin
- Parent := ToolPanel;
- DefaultWidth := 27;
- SkinDataName := 'toolbutton';
- Align := alRight;
- OnClick := MyDocToolButtonClick;
- NumGlyphs := 1;
- Glyph.LoadFromResourceName(HInstance, 'SP_MYDOC');
- end;
- //
- Bevel1 := TspSkinBevel.Create(Self);
- with Bevel1 do
- begin
- Parent := ToolPanel;
- Width := 27;
- Align := alRight;
- DividerMode := True;
- end;
- //
- ListToolButton := TspSkinSpeedButton.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, 'SP_LISTSTYLE');
- end;
- SmallIconToolButton := TspSkinSpeedButton.Create(Self);
- with SmallIconToolButton do
- begin
- Parent := ToolPanel;
- DefaultWidth := 27;
- SkinDataName := 'toolbutton';
- Align := alRight;
- GroupIndex := 1;
- OnClick := SmallIconToolButtonClick;
- NumGlyphs := 1;
- Glyph.LoadFromResourceName(HInstance, 'SP_SMALLICONSTYLE');
- end;
- IconToolButton := TspSkinSpeedButton.Create(Self);
- with IconToolButton do
- begin
- Parent := ToolPanel;
- DefaultWidth := 27;
- SkinDataName := 'toolbutton';
- Align := alRight;
- GroupIndex := 1;
- OnClick := IconToolButtonClick;
- NumGlyphs := 1;
- Glyph.LoadFromResourceName(HInstance, 'SP_ICONSTYLE');
- end;
- ReportToolButton := TspSkinSpeedButton.Create(Self);
- with ReportToolButton do
- begin
- Parent := ToolPanel;
- DefaultWidth := 27;
- SkinDataName := 'toolbutton';
- Align := alRight;
- GroupIndex := 1;
- OnClick := ReportToolButtonClick;
- NumGlyphs := 1;
- Glyph.LoadFromResourceName(HInstance, 'SP_REPORTSTYLE');
- end;
- Bevel2 := TspSkinBevel.Create(Self);
- with Bevel2 do
- begin
- Parent := ToolPanel;
- Width := 26;
- Align := alRight;
- DividerMode := True;
- end;
- Bevel3 := TspSkinBevel.Create(Self);
- with Bevel3 do
- begin
- Parent := ToolPanel;
- Width := 26;
- Align := alLeft;
- DividerMode := True;
- end;
- DriveBox := TspSkinShellDriveComboBox.Create(Self);
- with DriveBox do
- begin
- Parent := ToolPanel;
- OnChange := DCBChange;
- Align := alClient;
- end;
- BottomPanel := TspSkinPanel.Create(Self);
- with BottomPanel do
- begin
- Parent := Self;
- Align := alBottom;
- BorderStyle := bvNone;
- Height := 80;
- end;
- Splitter := TspSkinSplitter.Create(Self);
- with Splitter do
- begin
- Parent := Self;
- Align := alLeft;
- Width := 10;
- DefaultSize := 10;
- Beveled := False;
- end;
- DirTreeViewPanel := TspSkinExPanel.Create(Self);
- with DirTreeViewPanel do
- begin
- Parent := Self;
- Align := alLeft;
- RollKind := rkRollHorizontal;
- ShowCloseButton := False;
- Width := 200;
- end;
- FileListViewPanel := TspSkinPanel.Create(Self);
- with FileListViewPanel do
- begin
- Parent := Self;
- Align := alClient;
- BorderStyle := bvFrame;
- end;
- DTVVScrollBar := TspSkinScrollBar.Create(Self);
- with DTVVScrollBar do
- begin
- Kind := sbVertical;
- Parent := DirTreeViewPanel;
- Align := alRight;
- DefaultWidth := 19;
- Enabled := False;
- SkinDataName := 'vscrollbar';
- end;
- DTVHScrollBar := TspSkinScrollBar.Create(Self);
- with DTVHScrollBar do
- begin
- Parent := DirTreeViewPanel;
- Align := alBottom;
- DefaultHeight := 19;
- Enabled := False;
- BothMarkerWidth := 19;
- SkinDataName := 'hscrollbar';
- end;
- DirTreeView := TspSkinDirTreeView.Create(Self);
- with DirTreeView do
- begin
- Parent := DirTreeViewPanel;
- Align := alClient;
- HScrollBar := Self.DTVHScrollBar;
- VScrollBar := Self.DTVVScrollBar;
- OnChange := DTVChange;
- HideSelection := False;
- end;
- FLVHScrollBar := TspSkinScrollBar.Create(Self);
- with FLVHScrollBar do
- begin
- BothMarkerWidth := 19;
- Parent := FileListViewPanel;
- Align := alBottom;
- DefaultHeight := 19;
- Enabled := False;
- SkinDataName := 'hscrollbar';
- end;
- FLVVScrollBar := TspSkinScrollBar.Create(Self);
- with FLVVScrollBar do
- begin
- Kind := sbVertical;
- Parent := FileListViewPanel;
- Align := alRight;
- DefaultWidth := 19;
- Enabled := False;
- SkinDataName := 'vscrollbar';
- end;
- FileListView := TspSkinFileListView.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 := TspSkinEdit.Create(Self);
- with FileNameEdit do
- begin
- Parent := BottomPanel;
- Top := 10;
- Left := 70;
- Width := 300;
- DefaultHeight := 21;
- OnKeyPress := EditKeyPress;
- end;
- FilterComboBox := TspSkinFilterComboBox.Create(Self);
- with FilterComboBox do
- begin
- Parent := BottomPanel;
- Top := 45;
- Left := 70;
- Width := 300;
- DefaultHeight := 21;
- OnChange := FCBChange;
- end;
- OpenButton := TspSkinButton.Create(Self);
- with OpenButton do
- begin
- if SaveMode
- then
- Caption := SP_MSG_BTN_SAVE
- else
- Caption := SP_MSG_BTN_OPEN;
- CanFocused := True;
- Left := 390;
- Top := 10;
- Width := 70;
- DefaultHeight := 25;
- Parent := BottomPanel;
- OnClick := OpenButtonClick;
- end;
- CancelButton := TspSkinButton.Create(Self);
- with CancelButton do
- begin
- Caption := SP_MSG_BTN_CANCEL;
- CanFocused := True;
- Left := 390;
- Top := 45;
- Width := 70;
- DefaultHeight := 25;
- Parent := BottomPanel;
- ModalResult := mrCancel;
- Cancel := True;
- end;
- OpenFileLabel := TspSkinStdLabel.Create(Self);
- with OpenFileLabel do
- begin
- Caption := SP_MSG_FILENAME;
- Left := 10;
- Top := 10;
- AutoSize := True;
- Parent := BottomPanel;
- end;
- FileTypeLabel := TspSkinStdLabel.Create(Self);
- with FileTypeLabel do
- begin
- Caption := SP_MSG_FILETYPE;
- Left := 10;
- Top := 45;
- AutoSize := True;
- Parent := BottomPanel;
- end;
- ActiveControl := FileNameEdit;
- end;
- procedure TspOpenDlgForm.MyDocToolButtonClick(Sender: TObject);
- begin
- FileListView.Directory := GetPersonalRoot(Handle);
- end;
- procedure TspOpenDlgForm.ReportToolButtonClick(Sender: TObject);
- begin
- FileListView.ViewStyle := vsReport;
- FileListView.UpdateScrollBars;
- end;
- procedure TspOpenDlgForm.BackToolButtonClick(Sender: TObject);
- begin
- FileListView.OneLevelUp;
- FileListView.UpdateScrollBars;
- end;
- procedure TspOpenDlgForm.ListToolButtonClick(Sender: TObject);
- begin
- FileListView.ViewStyle := vsList;
- FileListView.UpdateScrollBars;
- end;
- procedure TspOpenDlgForm.SmallIconToolButtonClick(Sender: TObject);
- begin
- FileListView.ViewStyle := vsSmallIcon;
- FileListView.UpdateScrollBars;
- end;
- procedure TspOpenDlgForm.IconToolButtonClick(Sender: TObject);
- begin
- FileListView.ViewStyle := vsIcon;
- end;
- procedure TspOpenDlgForm.EditKeyPress;
- var
- FileName: String;
- begin
- inherited;
- if Key = #27
- then
- begin
- Close;
- end
- else
- 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 TspOpenDlgForm.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 TspOpenDlgForm.DCBChange(Sender: TObject);
- begin
- FromDCB := True;
- if not FromFLV and not FromFTV and (DirTreeView <> nil)
- then DirTreeView.Directory := DriveBox.Drive + ':';
- FromDCB := False;
- end;
- procedure TspOpenDlgForm.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 TspOpenDlgForm.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 TspOpenDlgForm.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 TspOpenDlgForm.FCBChange(Sender: TObject);
- begin
- FileListView.Mask := FilterComboBox.Mask;
- end;
- constructor TspSkinOpenDialog.Create(AOwner: TComponent);
- begin
- inherited Create(AOwner);
- FFiles := TStringList.Create;
- FMultiSelection := False;
- FSkinMessage := nil;
- 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 := 1;
- FFileName := '';
- TreePanelWidth := 200;
- ListViewStyle := vsList;
- end;
- destructor TspSkinOpenDialog.Destroy;
- begin
- FFiles.Free;
- FDefaultFont.Free;
- inherited Destroy;
- end;
- procedure TspSkinOpenDialog.SetDefaultFont;
- begin
- FDefaultFont.Assign(Value);
- end;
- procedure TspSkinOpenDialog.Notification;
- begin
- inherited Notification(AComponent, Operation);
- if (Operation = opRemove) and (AComponent = FSD) then FSD := nil;
- if (Operation = opRemove) and (AComponent = FCtrlFSD) then FCtrlFSD := nil;
- if (Operation = opRemove) and (AComponent = FSkinMessage)
- then
- FSkinMessage := nil;
- end;
- function TspSkinOpenDialog.GetTitle: string;
- begin
- Result := FTitle;
- end;
- procedure TspSkinOpenDialog.SetTitle(const Value: string);
- begin
- FTitle := Value;
- end;
- procedure TspSkinOpenDialog.Change;
- begin
- if Assigned(FOnChange) then FOnChange(Self);
- end;
- function TspSkinOpenDialog.Execute: Boolean;
- var
- CIndex, FW, FH: Integer;
- Path: String;
- begin
- FDlgFrm := TspOpenDlgForm.CreateEx(Application, FSaveMode);
- with FDlgFrm do
- try
- Caption := Self.Title;
- DSF.BorderIcons := [];
- DSF.SkinData := FSD;
- DSF.MenusSkinData := CtrlSkinData;
- DSF.AlphaBlend := AlphaBlend;
- DSF.AlphaBlendAnimation := AlphaBlendAnimation;
- DSF.AlphaBlendValue := AlphaBlendValue;
- DirTreeView.SkinData := FCtrlFSD;
- DirTreeView.SkinMessage := FSkinMessage;
- 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.Mask := FilterComboBox.Text;
- FileListView.MultiSelect := MultiSelection;
- FileListView.HeaderSkinDataName := FLVHeaderSkinDataName;
- FileListView.SkinData := FCtrlFSD;
- FileListView.SkinMessage := FSkinMessage;
- FilterComboBox.Filter := Self.Filter;
- FilterComboBox.ItemIndex := FFilterIndex - 1;
- //
- DirTreeViewPanel.SkinData := FCtrlFSD;
- FileListViewPanel.SkinData := FCtrlFSD;
- BottomPanel.SkinData := FCtrlFSD;
- ToolPanel.SkinData := FCtrlFSD;
- Bevel1.SkinData := FCtrlFSD;
- Bevel2.SkinData := FCtrlFSD;
- Bevel3.SkinData := FCtrlFSD;
- //
- DriveBox.SkinData := FCtrlFSD;
- if FCtrlFSD <> nil
- then
- CIndex := FCtrlFSD.GetControlIndex('toolcombobox')
- else
- CIndex := -1;
- if CIndex <> -1
- then
- DriveBox.SkinDataName := 'toolcombobox'
- else
- DriveBox.SkinDataName := 'combobox';
- //
- BackToolButton.SkinData := FCtrlFSD;
- ListToolButton.SkinData := FCtrlFSD;
- ReportToolButton.SkinData := FCtrlFSD;
- IconToolButton.SkinData := FCtrlFSD;
- SmallIconToolButton.SkinData := FCtrlFSD;
- MyDocToolButton.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 < DSF.GetMinWidth then FW := DSF.GetMinWidth;
- if FH < DSF.GetMinHeight then FH := DSF.GetMinHeight;
- end;
- ClientWidth := FW;
- ClientHeight := FH;
- Result := (ShowModal = mrOk);
- FFilterIndex := FilterComboBox.ItemIndex + 1;
- 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;
- Self.Files.Assign(FileListView.Files);
- Change;
- end;
- finally
- Free;
- FDlgFrm := nil;
- end;
- end;
- constructor TspSkinSaveDialog.Create(AOwner: TComponent);
- begin
- inherited;
- FTitle := 'Save file';
- FSaveMode := True;
- end;
- constructor TspSkinDirectoryEdit.Create(AOwner: TComponent);
- begin
- inherited;
- ControlStyle := ControlStyle - [csSetCaption];
- ButtonMode := True;
- OnButtonClick := ButtonClick;
- FSkinDataName := 'buttonedit';
- SD := TspSkinSelectDirectoryDialog.Create(Self);
- end;
- destructor TspSkinDirectoryEdit.Destroy;
- begin
- SD.Free;
- inherited;
- end;
- procedure TspSkinDirectoryEdit.ButtonClick;
- begin
- SD.Directory := Text;
- SD.SkinData := FDlgSkinData;
- SD.CtrlSkinData := FDlgCtrlSkinData;
- if SD.Execute then Text := SD.Directory;
- end;
- procedure TspSkinDirectoryEdit.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 TspSkinFileEdit.Create(AOwner: TComponent);
- begin
- inherited;
- ControlStyle := ControlStyle - [csSetCaption];
- ButtonMode := True;
- OnButtonClick := ButtonClick;
- FSkinDataName := 'buttonedit';
- FLVHeaderSkinDataName := 'resizebutton';
- OD := TspSkinOpenDialog.Create(Self);
- end;
- destructor TspSkinFileEdit.Destroy;
- begin
- OD.Free;
- inherited;
- end;
- function TspSkinFileEdit.GetFilter;
- begin
- Result := OD.Filter;
- end;
- procedure TspSkinFileEdit.SetFilter;
- begin
- OD.Filter := Value;
- end;
- procedure TspSkinFileEdit.ButtonClick;
- begin
- OD.FileName := Text;
- OD.SkinData := FDlgSkinData;
- OD.CtrlSkinData := FDlgCtrlSkinData;
- OD.LVHeaderSkinDataName := FLVHeaderSkinDataName;
- if OD.Execute then Text := OD.FileName;
- end;
- procedure TspSkinFileEdit.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 TspSkinSaveFileEdit.Create(AOwner: TComponent);
- begin
- inherited;
- ControlStyle := ControlStyle - [csSetCaption];
- FLVHeaderSkinDataName := 'resizebutton';
- ButtonMode := True;
- OnButtonClick := ButtonClick;
- FSkinDataName := 'buttonedit';
- OD := TspSkinSaveDialog.Create(Self);
- end;
- destructor TspSkinSaveFileEdit.Destroy;
- begin
- OD.Free;
- inherited;
- end;
- function TspSkinSaveFileEdit.GetFilter;
- begin
- Result := OD.Filter;
- end;
- procedure TspSkinSaveFileEdit.SetFilter;
- begin
- OD.Filter := Value;
- end;
- procedure TspSkinSaveFileEdit.ButtonClick;
- begin
- OD.FileName := Text;
- OD.SkinData := FDlgSkinData;
- OD.CtrlSkinData := FDlgCtrlSkinData;
- OD.LVHeaderSkinDataName := FLVHeaderSkinDataName;
- if OD.Execute then Text := OD.FileName;
- end;
- procedure TspSkinSaveFileEdit.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;
- // ======= TspSkinOpenPictureDialog ====== //
- constructor TspOpenPictureDlgForm.CreateEx;
- begin
- inherited CreateNew(AOwner);
- SaveMode := ASaveMode;
- KeyPreview := True;
- // BorderStyle := bsDialog;
- Position := poScreenCenter;
- DSF := TspDynamicSkinForm.Create(Self);
- FromFLV := False;
- FromFTV := False;
- ImagePanel := TspSkinPanel.Create(Self);
- with ImagePanel do
- begin
- BorderStyle := bvFrame;
- Parent := Self;
- Align := alRight;
- Width := 200;
- end;
- Splitter2 := TspSkinSplitter.Create(Self);
- with Splitter2 do
- begin
- Parent := Self;
- Align := alRight;
- Width := 10;
- DefaultSize := 10;
- Beveled := False;
- end;
- SBVScrollBar := TspSkinScrollBar.Create(Self);
- with SBVScrollBar do
- begin
- Kind := sbVertical;
- Parent := ImagePanel;
- Align := alRight;
- DefaultWidth := 19;
- Enabled := False;
- SkinDataName := 'vscrollbar';
- end;
- SBHScrollBar := TspSkinScrollBar.Create(Self);
- with SBHScrollBar do
- begin
- Parent := ImagePanel;
- Align := alBottom;
- DefaultHeight := 19;
- Enabled := False;
- BothMarkerWidth := 19;
- SkinDataName := 'hscrollbar';
- end;
- ScrollBox := TspSkinScrollBox.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 := TspSkinPanel.Create(Self);
- with ToolPanel do
- begin
- BorderStyle := bvNone;
- Parent := Self;
- Align := alTop;
- DefaultHeight := 25;
- SkinDataName := 'toolpanel';
- end;
- BackToolButton := TspSkinSpeedButton.Create(Self);
- with BackToolButton do
- begin
- Parent := ToolPanel;
- DefaultHeight := 25;
- DefaultWidth := 75;
- SkinDataName := 'toolbutton';
- Align := alLeft;
- OnClick := BackToolButtonClick;
- NumGlyphs := 1;
- Glyph.LoadFromResourceName(HInstance, 'SP_UP');
- end;
- MyDocToolButton := TspSkinSpeedButton.Create(Self);
- with MyDocToolButton do
- begin
- Parent := ToolPanel;
- DefaultWidth := 27;
- SkinDataName := 'toolbutton';
- Align := alRight;
- OnClick := MyDocToolButtonClick;
- NumGlyphs := 1;
- Glyph.LoadFromResourceName(HInstance, 'SP_MYDOC');
- end;
- //
- Bevel1 := TspSkinBevel.Create(Self);
- with Bevel1 do
- begin
- Parent := ToolPanel;
- Width := 27;
- Align := alRight;
- DividerMode := True;
- end;
- //
- ListToolButton := TspSkinSpeedButton.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, 'SP_LISTSTYLE');
- end;
- SmallIconToolButton := TspSkinSpeedButton.Create(Self);
- with SmallIconToolButton do
- begin
- Parent := ToolPanel;
- DefaultWidth := 27;
- SkinDataName := 'toolbutton';
- Align := alRight;
- GroupIndex := 1;
- OnClick := SmallIconToolButtonClick;
- NumGlyphs := 1;
- Glyph.LoadFromResourceName(HInstance, 'SP_SMALLICONSTYLE');
- end;
- IconToolButton := TspSkinSpeedButton.Create(Self);
- with IconToolButton do
- begin
- Parent := ToolPanel;
- DefaultWidth := 27;
- SkinDataName := 'toolbutton';
- Align := alRight;
- GroupIndex := 1;
- OnClick := IconToolButtonClick;
- NumGlyphs := 1;
- Glyph.LoadFromResourceName(HInstance, 'SP_ICONSTYLE');
- end;
- ReportToolButton := TspSkinSpeedButton.Create(Self);
- with ReportToolButton do
- begin
- Parent := ToolPanel;
- DefaultWidth := 27;
- SkinDataName := 'toolbutton';
- Align := alRight;
- GroupIndex := 1;
- OnClick := ReportToolButtonClick;
- NumGlyphs := 1;
- Glyph.LoadFromResourceName(HInstance, 'SP_REPORTSTYLE');
- end;
- Bevel4 := TspSkinBevel.Create(Self);
- with Bevel4 do
- begin
- Parent := ToolPanel;
- Width := 27;
- Align := alRight;
- DividerMode := True;
- end;
- StretchButton := TspSkinSpeedButton.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, 'SP_STRETCH');
- end;
- Bevel2 := TspSkinBevel.Create(Self);
- with Bevel2 do
- begin
- Parent := ToolPanel;
- Width := 26;
- Align := alRight;
- DividerMode := True;
- end;
- Bevel3 := TspSkinBevel.Create(Self);
- with Bevel3 do
- begin
- Parent := ToolPanel;
- Width := 26;
- Align := alLeft;
- DividerMode := True;
- end;
- DriveBox := TspSkinShellDriveComboBox.Create(Self);
- with DriveBox do
- begin
- Parent := ToolPanel;
- OnChange := DCBChange;
- Align := alClient;
- end;
- BottomPanel := TspSkinPanel.Create(Self);
- with BottomPanel do
- begin
- Parent := Self;
- Align := alBottom;
- BorderStyle := bvNone;
- Height := 80;
- end;
- Splitter := TspSkinSplitter.Create(Self);
- with Splitter do
- begin
- Parent := Self;
- Align := alLeft;
- Width := 10;
- DefaultSize := 10;
- Beveled := False;
- end;
- DirTreeViewPanel := TspSkinExPanel.Create(Self);
- with DirTreeViewPanel do
- begin
- Parent := Self;
- Align := alLeft;
- RollKind := rkRollHorizontal;
- ShowCloseButton := False;
- Width := 150;
- end;
- FileListViewPanel := TspSkinPanel.Create(Self);
- with FileListViewPanel do
- begin
- Parent := Self;
- Align := alClient;
- BorderStyle := bvFrame;
- end;
- DTVVScrollBar := TspSkinScrollBar.Create(Self);
- with DTVVScrollBar do
- begin
- Kind := sbVertical;
- Parent := DirTreeViewPanel;
- Align := alRight;
- DefaultWidth := 19;
- Enabled := False;
- SkinDataName := 'vscrollbar';
- end;
- DTVHScrollBar := TspSkinScrollBar.Create(Self);
- with DTVHScrollBar do
- begin
- Parent := DirTreeViewPanel;
- Align := alBottom;
- DefaultHeight := 19;
- Enabled := False;
- BothMarkerWidth := 19;
- SkinDataName := 'hscrollbar';
- end;
- DirTreeView := TspSkinDirTreeView.Create(Self);
- with DirTreeView do
- begin
- Parent := DirTreeViewPanel;
- Align := alClient;
- HScrollBar := Self.DTVHScrollBar;
- VScrollBar := Self.DTVVScrollBar;
- OnChange := DTVChange;
- HideSelection := False;
- end;
- FLVHScrollBar := TspSkinScrollBar.Create(Self);
- with FLVHScrollBar do
- begin
- BothMarkerWidth := 19;
- Parent := FileListViewPanel;
- Align := alBottom;
- DefaultHeight := 19;
- Enabled := False;
- SkinDataName := 'hscrollbar';
- end;
- FLVVScrollBar := TspSkinScrollBar.Create(Self);
- with FLVVScrollBar do
- begin
- Kind := sbVertical;
- Parent := FileListViewPanel;
- Align := alRight;
- DefaultWidth := 19;
- Enabled := False;
- SkinDataName := 'vscrollbar';
- end;
- FileListView := TspSkinFileListView.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 := TspSkinEdit.Create(Self);
- with FileNameEdit do
- begin
- Parent := BottomPanel;
- Top := 10;
- Left := 70;
- Width := 300;
- DefaultHeight := 21;
- OnKeyPress := EditKeyPress;
- end;
- FilterComboBox := TspSkinFilterComboBox.Create(Self);
- with FilterComboBox do
- begin
- Parent := BottomPanel;
- Top := 45;
- Left := 70;
- Width := 300;
- DefaultHeight := 21;
- OnChange := FCBChange;
- end;
- OpenButton := TspSkinButton.Create(Self);
- with OpenButton do
- begin
- if SaveMode
- then
- Caption := SP_MSG_BTN_SAVE
- else
- Caption := SP_MSG_BTN_OPEN;
- CanFocused := True;
- Left := 390;
- Top := 10;
- Width := 70;
- DefaultHeight := 25;
- Parent := BottomPanel;
- OnClick := OpenButtonClick;
- end;
- CancelButton := TspSkinButton.Create(Self);
- with CancelButton do
- begin
- Caption := SP_MSG_BTN_CANCEL;
- CanFocused := True;
- Left := 390;
- Top := 45;
- Width := 70;
- DefaultHeight := 25;
- Parent := BottomPanel;
- ModalResult := mrCancel;
- Cancel := True;
- end;
- OpenFileLabel := TspSkinStdLabel.Create(Self);
- with OpenFileLabel do
- begin
- Caption := SP_MSG_FILENAME;
- Left := 10;
- Top := 10;
- AutoSize := True;
- Parent := BottomPanel;
- end;
- FileTypeLabel := TspSkinStdLabel.Create(Self);
- with FileTypeLabel do
- begin
- Caption := SP_MSG_FILETYPE;
- Left := 10;
- Top := 45;
- AutoSize := True;
- Parent := BottomPanel;
- end;
- ActiveControl := FileNameEdit;
- end;
- procedure TspOpenPictureDlgForm.MyDocToolButtonClick(Sender: TObject);
- begin
- FileListView.Directory := GetPersonalRoot(Handle);
- end;
- procedure TspOpenPictureDlgForm.ReportToolButtonClick(Sender: TObject);
- begin
- FileListView.ViewStyle := vsReport;
- FileListView.UpdateScrollBars;
- end;
- procedure TspOpenPictureDlgForm.BackToolButtonClick(Sender: TObject);
- begin
- FileListView.OneLevelUp;
- FileListView.UpdateScrollBars;
- end;
- procedure TspOpenPictureDlgForm.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 TspOpenPictureDlgForm.ListToolButtonClick(Sender: TObject);
- begin
- FileListView.ViewStyle := vsList;
- FileListView.UpdateScrollBars;
- end;
- procedure TspOpenPictureDlgForm.SmallIconToolButtonClick(Sender: TObject);
- begin
- FileListView.ViewStyle := vsSmallIcon;
- FileListView.UpdateScrollBars;
- end;
- procedure TspOpenPictureDlgForm.IconToolButtonClick(Sender: TObject);
- begin
- FileListView.ViewStyle := vsIcon;
- end;
- procedure TspOpenPictureDlgForm.EditKeyPress;
- var
- FileName: String;
- begin
- inherited;
- if Key = #27
- then
- begin
- Close;
- end
- else
- 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 TspOpenPictureDlgForm.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 TspOpenPictureDlgForm.DCBChange(Sender: TObject);
- begin
- FromDCB := True;
- if not FromFLV and not FromFTV and (DirTreeView <> nil)
- then DirTreeView.Directory := DriveBox.Drive + ':';
- FromDCB := False;
- end;
- procedure TspOpenPictureDlgForm.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 TspOpenPictureDlgForm.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 TspOpenPictureDlgForm.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 TspOpenPictureDlgForm.FCBChange(Sender: TObject);
- begin
- FileListView.Mask := FilterComboBox.Mask;
- end;
- constructor TspSkinOpenPictureDialog.Create(AOwner: TComponent);
- begin
- inherited Create(AOwner);
- FFiles := TStringList.Create;
- FMultiSelection := False;
- FSkinMessage := nil;
- 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 := 1;
- FFileName := '';
- TreePanelWidth := 150;
- ImagePanelWidth := 200;
- ListViewStyle := vsList;
- end;
- destructor TspSkinOpenPictureDialog.Destroy;
- begin
- FFiles.Free;
- FDefaultFont.Free;
- inherited Destroy;
- end;
- procedure TspSkinOpenPictureDialog.SetDefaultFont;
- begin
- FDefaultFont.Assign(Value);
- end;
- procedure TspSkinOpenPictureDialog.Notification;
- begin
- inherited Notification(AComponent, Operation);
- if (Operation = opRemove) and (AComponent = FSD) then FSD := nil;
- if (Operation = opRemove) and (AComponent = FCtrlFSD) then FCtrlFSD := nil;
- if (Operation = opRemove) and (AComponent = FSkinMessage)
- then
- FSkinMessage := nil;
- end;
- function TspSkinOpenPictureDialog.GetTitle: string;
- begin
- Result := FTitle;
- end;
- procedure TspSkinOpenPictureDialog.SetTitle(const Value: string);
- begin
- FTitle := Value;
- end;
- procedure TspSkinOpenPictureDialog.Change;
- begin
- if Assigned(FOnChange) then FOnChange(Self);
- end;
- function TspSkinOpenPictureDialog.Execute: Boolean;
- var
- CIndex, i, FW, FH: Integer;
- Path: String;
- begin
- FDlgFrm := TspOpenPictureDlgForm.CreateEx(Application, FSaveMode);
- with FDlgFrm do
- try
- Caption := Self.Title;
- DSF.BorderIcons := [];
- DSF.SkinData := FSD;
- DSF.MenusSkinData := CtrlSkinData;
- DSF.AlphaBlend := AlphaBlend;
- DSF.AlphaBlendAnimation := AlphaBlendAnimation;
- DSF.AlphaBlendValue := AlphaBlendValue;
- DirTreeView.SkinData := FCtrlFSD;
- DirTreeView.SkinMessage := FSkinMessage;
- 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.MultiSelect := MultiSelection;
- FileListView.Mask := FilterComboBox.Text;
- FileListView.HeaderSkinDataName := FLVHeaderSkinDataName;
- FileListView.SkinData := FCtrlFSD;
- FileListView.SkinMessage := FSkinMessage;
- FilterComboBox.Filter := Self.Filter;
- FilterComboBox.ItemIndex := FFilterIndex - 1;
- //
- 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;
- if FCtrlFSD <> nil
- then
- CIndex := FCtrlFSD.GetControlIndex('toolcombobox')
- else
- CIndex := -1;
- if CIndex <> -1
- then
- DriveBox.SkinDataName := 'toolcombobox'
- else
- DriveBox.SkinDataName := 'combobox';
- //
- Bevel4.SkinData := FCtrlFSD;
- BackToolButton.SkinData := FCtrlFSD;
- ListToolButton.SkinData := FCtrlFSD;
- ReportToolButton.SkinData := FCtrlFSD;
- IconToolButton.SkinData := FCtrlFSD;
- SmallIconToolButton.SkinData := FCtrlFSD;
- MyDocToolButton.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 < DSF.GetMinWidth then FW := DSF.GetMinWidth;
- if FH < DSF.GetMinHeight then FH := DSF.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);
- FFilterIndex := FilterComboBox.ItemIndex + 1;
- 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;
- Self.Files.Assign(FileListView.Files);
- Change;
- end;
- finally
- Free;
- FDlgFrm := nil;
- end;
- end;
- constructor TspSkinSavePictureDialog.Create(AOwner: TComponent);
- begin
- inherited;
- FTitle := 'Save picture';
- FSaveMode := True;
- end;
- end.