📄 bsskinshellctrls.pas
字号:
procedure EditKeyPress(Sender: TObject; var Key: Char);
procedure UpToolButtonClick(Sender: TObject);
procedure BackToolButtonClick(Sender: TObject);
procedure NewFolderToolButtonClick(Sender: TObject);
procedure ReportItemClick(Sender: TObject);
procedure ListItemClick(Sender: TObject);
procedure SmallIconItemClick(Sender: TObject);
procedure IconItemClick(Sender: TObject);
end;
TbsSkinOpenSoundDialog = class(TComponent)
private
FOnPlayButtonClick: TNotifyEvent;
FOnStopButtonClick: TNotifyEvent;
FDialogWidth, FDialogHeight: Integer;
FDialogMinWidth, FDialogMinHeight: Integer;
FPaintPanelSize: Integer;
FOnFolderChange: TNotifyEvent;
FCheckFileExists: Boolean;
FMultiSelection: Boolean;
FSD: TbsSkinData;
FCtrlFSD: TbsSkinData;
FLVHeaderSkinDataName: String;
FDefaultFont: TFont;
FTitle: String;
FDlgFrm: TbsOpenSoundDlgForm;
FOnChange: TNotifyEvent;
FInitialDir: String;
FFilter: String;
FFileName: String;
FFilterIndex: Integer;
FAlphaBlend: Boolean;
FAlphaBlendValue: Byte;
FAlphaBlendAnimation: Boolean;
FCtrlAlphaBlend: Boolean;
FCtrlAlphaBlendValue: Byte;
FCtrlAlphaBlendAnimation: Boolean;
FFiles: TStringList;
function GetTitle: string;
procedure SetTitle(const Value: string);
procedure SetDefaultFont(Value: TFont);
procedure SetFileName(const Value: String);
protected
FSaveMode: Boolean;
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
procedure Change;
public
ListViewStyle: TViewStyle;
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
function Execute: Boolean;
property Files: TStringList read FFiles;
function GetSelectedFile: String;
published
property DialogWidth: Integer read FDialogWidth write FDialogWidth;
property DialogHeight: Integer read FDialogHeight write FDialogHeight;
property DialogMinWidth: Integer read FDialogMinWidth write FDialogMinWidth;
property DialogMinHeight: Integer read FDialogMinHeight write FDialogMinHeight;
property PaintPanelSize: Integer read FPaintPanelSize write FPaintPanelSize;
property CheckFileExists: Boolean read FCheckFileExists write FCheckFileExists;
property MultiSelection: Boolean read FMultiSelection write FMultiSelection;
property AlphaBlend: Boolean read FAlphaBlend write FAlphaBlend;
property AlphaBlendValue: Byte read FAlphaBlendValue write FAlphaBlendValue;
property AlphaBlendAnimation: Boolean
read FAlphaBlendAnimation write FAlphaBlendAnimation;
property CtrlAlphaBlend: Boolean read FCtrlAlphaBlend write FCtrlAlphaBlend;
property CtrlAlphaBlendValue: Byte read FCtrlAlphaBlendValue write FCtrlAlphaBlendValue;
property CtrlAlphaBlendAnimation: Boolean
read FCtrlAlphaBlendAnimation write FCtrlAlphaBlendAnimation;
property LVHeaderSkinDataName: String
read FLVHeaderSkinDataName write FLVHeaderSkinDataName;
property SkinData: TbsSkinData read FSD write FSD;
property CtrlSkinData: TbsSkinData read FCtrlFSD write FCtrlFSD;
property DefaultFont: TFont read FDefaultFont write SetDefaultFont;
property Title: string read GetTitle write SetTitle;
property InitialDir: String read FInitialDir write FInitialDir;
property Filter: String read FFilter write FFilter;
property FilterIndex: Integer read FFilterIndex write FFilterIndex;
property FileName: String read FFileName write SetFileName;
property OnFolderChange: TNotifyEvent read FOnFolderChange write FOnFolderChange;
property OnPlayButtonClick: TNotifyEvent
read FOnPlayButtonClick write FOnPlayButtonClick;
property OnStopButtonClick: TNotifyEvent
read FOnStopButtonClick write FOnStopButtonClick;
end;
TbsSkinSaveSoundDialog = class(TbsSkinOpenSoundDialog)
public
constructor Create(AOwner: TComponent); override;
end;
procedure InvokeContextMenu(Owner: TWinControl; AFolder: TbsShellFolder; X, Y: Integer);
resourcestring
SShellNoDetails = 'Unable to retrieve folder details for "%s". Error code $%x';
SCallLoadDetails = '%s: Missing call to LoadColumnDetails';
SPalletePage = 'Samples';
SPropertyName = 'Root';
SRenamedFailedError = 'Rename to %s failed';
SErrorSettingPath = 'Error setting path: "%s"';
const
SRFDesktop = 'rfDesktop';
SCmdVerbOpen = 'open';
SCmdVerbRename = 'rename';
SCmdVerbDelete = 'delete';
SCmdVerbPaste = 'paste';
implementation
{$R bsSkinShellCtrls}
uses ShellAPI, ComObj, TypInfo, Consts, Math, bsConst, Masks;
const
nFolder: array[TRootFolder] of Integer =
(CSIDL_DESKTOP, CSIDL_DRIVES, CSIDL_NETWORK, CSIDL_BITBUCKET, CSIDL_APPDATA,
CSIDL_COMMON_DESKTOPDIRECTORY, CSIDL_COMMON_PROGRAMS, CSIDL_COMMON_STARTMENU,
CSIDL_COMMON_STARTUP, CSIDL_CONTROLS, CSIDL_DESKTOPDIRECTORY, CSIDL_FAVORITES,
CSIDL_FONTS, CSIDL_INTERNET, CSIDL_PERSONAL, CSIDL_PRINTERS, CSIDL_PRINTHOOD,
CSIDL_PROGRAMS, CSIDL_RECENT, CSIDL_SENDTO, CSIDL_STARTMENU, CSIDL_STARTUP,
CSIDL_TEMPLATES);
SHGFI = SHGFI_SYSICONINDEX or SHGFI_SMALLICON;
var
cmvProperties: PChar = 'properties'; { Do not localize }
ICM: IContextMenu = nil;
ICM2: IContextMenu2 = nil;
DesktopFolder: TbsShellFolder = nil;
CS : TRTLCriticalSection;
{ PIDL manipulation }
procedure debug(Comp:TComponent; msg:string);
begin
ShowMessage(Comp.Name + ':' + msg);
end;
function CreatePIDL(Size: Integer): PItemIDList;
var
Malloc: IMalloc;
begin
OleCheck(SHGetMalloc(Malloc));
Result := Malloc.Alloc(Size);
if Assigned(Result) then
FillChar(Result^, Size, 0);
end;
function NextPIDL(IDList: PItemIDList): PItemIDList;
begin
Result := IDList;
Inc(PChar(Result), IDList^.mkid.cb);
end;
procedure StripLastID(IDList: PItemIDList);
var
MarkerID: PItemIDList;
begin
MarkerID := IDList;
if Assigned(IDList) then
begin
while IDList.mkid.cb <> 0 do
begin
MarkerID := IDList;
IDList := NextPIDL(IDList);
end;
MarkerID.mkid.cb := 0;
end;
end;
function GetItemCount(IDList: PItemIDList): Integer;
begin
Result := 0;
while IDList^.mkid.cb <> 0 do
begin
Inc(Result);
IDList := NextPIDL(IDList);
end;
end;
function GetPIDLSize(IDList: PItemIDList): Integer;
begin
Result := 0;
if Assigned(IDList) then
begin
Result := SizeOf(IDList^.mkid.cb);
while IDList^.mkid.cb <> 0 do
begin
Result := Result + IDList^.mkid.cb;
IDList := NextPIDL(IDList);
end;
end;
end;
function CopyPIDL(IDList: PItemIDList): PItemIDList;
var
Size: Integer;
begin
Size := GetPIDLSize(IDList);
Result := CreatePIDL(Size);
if Assigned(Result) then
CopyMemory(Result, IDList, Size);
end;
function ConcatPIDLs(IDList1, IDList2: PItemIDList): PItemIDList;
var
cb1, cb2: Integer;
begin
if Assigned(IDList1) then
cb1 := GetPIDLSize(IDList1) - SizeOf(IDList1^.mkid.cb)
else
cb1 := 0;
cb2 := GetPIDLSize(IDList2);
Result := CreatePIDL(cb1 + cb2);
if Assigned(Result) then
begin
if Assigned(IDList1) then
CopyMemory(Result, IDList1, cb1);
CopyMemory(PChar(Result) + cb1, IDList2, cb2);
end;
end;
procedure DisposePIDL(PIDL: PItemIDList);
var
MAlloc: IMAlloc;
begin
OLECheck(SHGetMAlloc(MAlloc));
MAlloc.Free(PIDL);
end;
function RelativeFromAbsolute(AbsoluteID: PItemIDList): PItemIDList;
begin
Result := AbsoluteID;
while GetItemCount(Result) > 1 do
Result := NextPIDL(Result);
Result := CopyPIDL(Result);
end;
function CreatePIDLList(ID: PItemIDList): TList;
var
TempID: PItemIDList;
begin
Result := TList.Create;
TempID := ID;
while TempID.mkid.cb <> 0 do
begin
TempID := CopyPIDL(TempID);
Result.Insert(0, TempID);
StripLastID(TempID);
end;
end;
procedure DestroyPIDLList(List: TList);
var
I: Integer;
begin
If List = nil then Exit;
for I := 0 to List.Count-1 do
DisposePIDL(List[I]);
List.Free;
end;
{ Miscellaneous }
procedure NoFolderDetails(AFolder: TbsShellFolder; HR: HResult);
begin
Raise EInvalidPath.CreateFmt(SShellNoDetails, [AFolder.DisplayName, HR]);
end;
function DesktopShellFolder: IShellFolder;
begin
OleCheck(SHGetDesktopFolder(Result));
end;
procedure CreateDesktopFolder;
var
DesktopPIDL: PItemIDList;
begin
SHGetSpecialFolderLocation(0, nFolder[rfDesktop], DesktopPIDL);
if DesktopPIDL <> nil then
DesktopFolder := TbsShellFolder.Create(nil, DesktopPIDL, DesktopShellFolder);
end;
function SamePIDL(ID1, ID2: PItemIDList): boolean;
begin
Result := DesktopShellFolder.CompareIDs(0, ID1, ID2) = 0;
end;
function DesktopPIDL: PItemIDList;
begin
OleCheck(SHGetSpecialFolderLocation(0, nFolder[rfDesktop], Result));
end;
function GetCSIDLType(const Value: string): TRootFolder;
begin
{$R+}
Result := TRootFolder(GetEnumValue(TypeInfo(TRootFolder), Value))
{$R-}
end;
function IsElement(Element, Flag: Integer): Boolean;
begin
Result := Element and Flag <> 0;
end;
function GetShellImage(PIDL: PItemIDList; Large, Open: Boolean): Integer;
var
FileInfo: TSHFileInfo;
Flags: Integer;
begin
Flags := SHGFI_PIDL or SHGFI_SYSICONINDEX;
if Open then Flags := Flags or SHGFI_OPENICON;
if Large then Flags := Flags or SHGFI_LARGEICON
else Flags := Flags or SHGFI_SMALLICON;
SHGetFileInfo(PChar(PIDL),
0,
FileInfo,
SizeOf(FileInfo),
Flags);
Result := FileInfo.iIcon;
end;
function GetCaps(ParentFolder: IShellFolder; PIDL: PItemIDList): TbsShellFolderCapabilities;
var
Flags: LongWord;
begin
Result := [];
Flags := SFGAO_CAPABILITYMASK;
ParentFolder.GetAttributesOf(1, PIDL, Flags);
if IsElement(SFGAO_CANCOPY, Flags) then Include(Result, fcCanCopy);
if IsElement(SFGAO_CANDELETE, Flags) then Include(Result, fcCanDelete);
if IsElement(SFGAO_CANLINK, Flags) then Include(Result, fcCanLink);
if IsElement(SFGAO_CANMOVE, Flags) then Include(Result, fcCanMove);
if IsElement(SFGAO_CANRENAME, Flags) then Include(Result, fcCanRename);
if IsElement(SFGAO_DROPTARGET, Flags) then Include(Result, fcDropTarget);
if IsElement(SFGAO_HASPROPSHEET, Flags) then Include(Result, fcHasPropSheet);
end;
function GetProperties(ParentFolder: IShellFolder; PIDL: PItemIDList): TbsShellFolderProperties;
var
Flags: LongWord;
begin
Result := [];
if ParentFolder = nil then Exit;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -