📄 systemlistview.pas
字号:
property ParentShowHint;
{$IFDEF DFS_COMPILER_4_UP}
property ParentBiDiMode;
{$ENDIF}
property ShowHint;
property PopupMenu;
property ShowColumnHeaders;
property TabOrder;
property TabStop
default True;
property ViewStyle;
property Visible;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
property LargeImages;
property StateImages;
{$ELSE}
{$IFDEF DFS_SLV_USE_ENHLISTVIEW}
property AutoColumnSort;
property AutoSortStyle;
property AutoResort;
property AutoSortAscending;
property ReverseSortArrows;
property ShowSortArrows;
property SaveSettings;
property Style;
property OnMeasureItem;
property OnDrawItem;
property OnDrawSubItem;
property OnAfterDefaultDrawItem;
property OnDrawHeader;
property OnSortItems;
property OnSortBegin;
property OnSortFinished;
property OnEditCanceled;
{ Publish TCustomListView inherited protected properties }
property Align;
{$IFDEF DFS_COMPILER_4_UP}
property Anchors;
property BiDiMode;
{$ENDIF}
property BorderStyle;
{$IFDEF DFS_COMPILER_4_UP}
property BorderWidth;
{$ENDIF}
property Color;
property ColumnClick;
property OnClick;
property OnDblClick;
{$IFDEF DFS_COMPILER_4_UP}
property Constraints;
{$ENDIF}
property Ctl3D;
{$IFDEF DFS_COMPILER_4_UP}
property DragKind;
{$ENDIF}
property DragMode;
property ReadOnly
default False;
property Enabled;
property Font;
{$IFDEF DFS_COMPILER_4_UP}
property FullDrag;
{$ENDIF}
property HideSelection;
property IconOptions;
property AllocBy;
property MultiSelect;
property OnChange;
property OnChanging;
property OnColumnClick;
property OnDeletion;
property OnEdited;
property OnEditing;
{$IFDEF DFS_COMPILER_4_UP}
property OnEndDock;
{$ENDIF}
property OnEnter;
property OnExit;
property OnInsert;
property OnDragDrop;
property OnDragOver;
property DragCursor;
property OnStartDrag;
property OnEndDrag;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
{$IFDEF DFS_COMPILER_4_UP}
property OnResize;
property OnSelectItem;
property OnStartDock;
{$ENDIF}
property ParentColor
default False;
property ParentFont;
property ParentShowHint;
{$IFDEF DFS_COMPILER_4_UP}
property ParentBiDiMode;
{$ENDIF}
property ShowHint;
property PopupMenu;
property ShowColumnHeaders;
property TabOrder;
property TabStop
default True;
property ViewStyle;
property Visible;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
property LargeImages;
property SmallImages;
property StateImages;
{$ELSE}
{ Published protected properties }
property Align;
property AllocBy;
{$IFDEF DFS_COMPILER_4_UP}
property Anchors;
property BiDiMode;
{$ENDIF}
property BorderStyle;
{$IFDEF DFS_COMPILER_4_UP}
property BorderWidth;
{$ENDIF}
{$IFDEF DFS_COMPILER_3_UP}
property Checkboxes;
{$ENDIF}
property Color;
property ColumnClick;
{$IFDEF DFS_COMPILER_4_UP}
property Constraints;
{$ENDIF}
property Ctl3D;
property DragCursor;
{$IFDEF DFS_COMPILER_4_UP}
property DragKind;
{$ENDIF}
property DragMode;
{$IFDEF DFS_COMPILER_3_UP}
property Enabled;
{$ENDIF}
{$IFDEF DFS_COMPILER_4_UP}
property FlatScrollBars;
{$ENDIF}
property Font;
{$IFDEF DFS_COMPILER_4_UP}
property FullDrag;
{$ENDIF}
{$IFDEF DFS_COMPILER_3_UP}
property GridLines;
{$ENDIF}
property HideSelection;
{$IFDEF DFS_COMPILER_3_UP}
property HotTrack;
{$ENDIF}
{$IFDEF DFS_COMPILER_4_UP}
property HotTrackStyles;
{$ENDIF}
property IconOptions;
property MultiSelect;
property OnChange;
property OnChanging;
property OnClick;
property OnColumnClick;
property OnCompare;
{$IFDEF DFS_COMPILER_4_UP}
property OnCustomDraw;
property OnCustomDrawItem;
property OnCustomDrawSubItem;
property OnData;
property OnDataFind;
property OnDataHint;
property OnDataStateChange;
{$ENDIF}
property OnDblClick;
property OnDeletion;
property OnDragDrop;
property OnDragOver;
{$IFDEF DFS_COMPILER_4_UP}
property OnDrawItem;
{$ENDIF}
property OnEdited;
property OnEditing;
{$IFDEF DFS_COMPILER_4_UP}
property OnEndDock;
{$ENDIF}
property OnEndDrag;
property OnEnter;
property OnExit;
{$IFDEF DFS_COMPILER_4_UP}
property OnGetImageIndex;
{$ENDIF}
property OnInsert;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
{$IFDEF DFS_COMPILER_4_UP}
property OnResize;
property OnSelectItem;
property OnStartDock;
{$ENDIF}
property OnStartDrag;
{$IFDEF DFS_COMPILER_4_UP}
property OwnerDraw;
property ParentBiDiMode;
{$ENDIF}
{$IFDEF DFS_COMPILER_3_UP}
property ParentColor default False;
property ParentFont;
{$ENDIF}
property ParentShowHint;
property PopupMenu;
property ReadOnly default False;
{$IFDEF DFS_COMPILER_3_UP}
property RowSelect;
{$ENDIF}
property ShowColumnHeaders;
property ShowHint;
property SortType;
property TabOrder;
property TabStop default True;
property ViewStyle;
property Visible;
{$ENDIF}
{$ENDIF}
end;
implementation
uses
ShellAPI, MaskSearch,
{$IFDEF DFS_COMPILER_4_UP} ImgList, {$ENDIF}
{$IFDEF DFS_COMPILER_3_UP} ComObj, {$ELSE} OleAuto, {$ENDIF}
Registry;
const
SORT_ALPHA = -1;
SORT_CURRENT = -2;
var
NewCount: Longint;
function Commaize(S: string): string;
var
Len: Integer;
begin
Len := Length(S);
if Len > 3 then
begin
Result := '';
while Len > 3 do
begin
Insert(',' + Copy(S, Len-2, 3), Result, 1);
Delete(S, Len-2, 3);
Dec(Len, 3);
end;
if Len > 0 then
Insert(S, Result, 1);
end else
Result := S;
end;
constructor TdfsSystemListView.Create(AOwner: TComponent);
type
PWordArray = ^TWordArray;
TWordArray = array[0..300] of word;
var
OptRIF : TRegIniFile;
BufferPtr: PWordArray;
DataBuffer : array[0..4] of word;
DataSize: integer;
x: integer;
begin
// These need to be before inherited!
FLastNodeWasDesktop := FALSE;
FNeedsReset := FALSE;
FLastNode := NIL;
FCurrentPIDL := NIL;
// Set the defaults.
FAutoscroll := FALSE;
FShowErrorsInMsgBox := TRUE;
FShowHiddenFiles := TRUE;
FShowFolders := TRUE;
FColumnType := ctFileSystem;
FFileMaskList := TStringList.Create;
{$IFNDEF DFS_SLV_USING_ELV}
FLastColumnIndexSort := -1;
{$ENDIF}
inherited Create(AOwner);
FPopupMenuMethod := pmmContextUser;
// Added by Fabrice FOUQUET 30/03/98
// Read the columns width for Explorer in the registry
// Must we do to update this value in destroy event ?
// Default values:
DataBuffer[0] := 120;
DataBuffer[1] := 60;
DataBuffer[2] := 120;
DataBuffer[3] := 120;
DataBuffer[4] := 60;
OptRIF := TRegIniFile.Create('Software\Microsoft\Windows\CurrentVersion\Explorer');
try
DataSize := optRIF.GetDataSize('DirectoryCols');
if DataSize > 0 then
begin
GetMem(BufferPtr, DataSize);
try
OptRIF.ReadBinaryData('DirectoryCols', BufferPtr^, DataSize);
for x := 0 to (DataSize div SizeOf(Word))-1 do
begin
if x > 4 then break; {//}
DataBuffer[x] := BufferPtr^[x];
end;
finally
FreeMem(BufferPtr);
end;
end;
finally
OptRIF.Free;
end;
SetColumnWidths(DataBuffer[0], DataBuffer[1], DataBuffer[2], DataBuffer[3],
DataBuffer[4]);
end; {Create}
destructor TdfsSystemListView.Destroy;
begin
FreePIDL(FCurrentPIDL);
{$IFNDEF DFS_NO_COM_CLEANUP}
if FCurrentShellFolder <> NIL then
FCurrentShellFolder.Release;
{$ENDIF}
LargeImages.Free;
SmallImages.Free;
FFileMaskList.Free;
inherited Destroy;
end;
procedure TdfsSystemListView.CreateWnd;
var
x: integer;
{$IFDEF DFS_COMPILER_5_UP}
ExtStyle: DWORD;
{$ENDIF}
begin
inherited CreateWnd;
{$IFDEF DFS_COMPILER_5_UP}
// Silly VCL explicitly turns on subitem images
ExtStyle := ListView_GetExtendedListViewStyle(Handle);
ExtStyle := ExtStyle and not LVS_EX_SUBITEMIMAGES;
ListView_SetExtendedListViewStyle(Handle, ExtStyle);
{$ENDIF}
if not (csLoading in ComponentState) then
CreateColumns(FColumnType);
if FRecreatingWnd or FNeedsReset then
begin
if FRecreatingWnd then
begin
// Re-creation restores Data prop pointer values, but we've freed them all
for x := 0 to Items.Count - 1 do
Items[x].Data := NIL;
end;
FRecreatingWnd := FALSE;
Reset;
end;
end;
procedure TdfsSystemListView.DestroyWnd;
begin
// The window is only being recreated.
FRecreatingWnd := TRUE;
inherited DestroyWnd;
FNeedsReset := TRUE;
end;
procedure TdfsSystemListView.Loaded;
begin
inherited Loaded;
CreateColumns(FColumnType);
FNeedsReset := TRUE; // Force the reset
Reset; // We've finished loading, we can populate the list now.
end;
function TdfsSystemListView.GetItems: TListItems;
begin
Result := inherited Items;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -