Hi,
I added for TShellListView Windows SystemImages. It don't copies them. It shares systemimage-handle.
You can integate it in to LCL-Shellcontrols. Here is Code:
Unit for handling imagelist and iconindex:unit lfmosfuncwin;
{$mode objfpc}{$H+}
interface
uses Windows, ComCtrls;
procedure SetListViewImgListToSys(AListView :TCustomListView; ALarge: Boolean);
function GetFileSysImageIndex(AFName: string): Integer;
implementation
const
SHGFI_SMALLICON = $000000001;
SHGFI_LARGEICON = $000000000;
SHGFI_SYSICONINDEX = $000004000;
SHGFI_ICON = $000000100;
IsImgLarge: array[Boolean] of Integer = (SHGFI_SMALLICON, SHGFI_LARGEICON);
function GetSysImageListHandle(ALarge: Boolean): HIMAGELIST;
var aFileInfo: TSHFileInfo;
begin
//don't needed initial zereo: ZeroMemory(@aFileInfo,sizeof(TSHFileInfo));
Result := SHGetFileInfo('', 0, aFileInfo, SizeOf(aFileInfo), SHGFI_SYSICONINDEX or IsImgLarge[ALarge]);
end;
procedure SetListViewImgListToSys(AListView :TCustomListView; ALarge: Boolean);
begin
ListView_SetImageList(AListView.Handle,GetSysImageListHandle(ALarge), IsImgLarge[ALarge]); //SHGFI_SMALLICON);
end;
function GetFileSysImageIndex(AFName: string): Integer;
var aFileInfo: TSHFileInfo;
begin
//don't needed initial zereo: ZeroMemory(@aFileInfo,sizeof(TSHFileInfo));
SHGetFileInfo(PChar(AFName),0,aFileInfo, SizeOf(aFileInfo), SHGFI_ICON or SHGFI_SYSICONINDEX);
Result:=aFileInfo.iIcon;
end;
Changes in ShellCtrls.pastype
TCustomShellListView = class(TCustomListView)
//...
protected
procedure SetParent(NewParent: TWinControl); override;
//...
end;
implementation
{$ifdef windows}
uses Windows, lfmosfuncwin;
{$endif}
//...
procedure TCustomShellListView.SetParent(NewParent: TWinControl);
begin
inherited SetParent(NewParent);
SetListViewImgListToSys(self, true); //large icons
SetListViewImgListToSys(self, false); //small icons
end;
//.....
procedure TCustomShellListView.PopulateWithRoot();
//.....
begin
//.....
try
//near line 715 change:
TCustomShellTreeView.GetFilesInDir(FRoot, FMask, FObjectTypes, Files, fstFoldersFirst); //add fstFoldersFirst for better sorting
//...
//Add near line 735 inLoop after Line:
//NewItem.SubItems.Add(ExtractFileExt(CurFileName));
//this Line
NewItem.ImageIndex:=GetFileSysImageIndex(CurFilePath);
//...
end;
// in function:
procedure TCustomShellListView.Resize;
begin
//change this:
//if Self.Columns.Count < 3 then Exit;
//to this:
if (ViewStyle<>vsReport)or(Self.Columns.Count < 3) then Exit;
//because in List or IconView Columns are to wide.
//...
end;
You can do same thing for TShellTreeView. For TShellTreeView you need only Smallimage-List.
I add my sources as attachment you can use it too.
Edit2:I made modifications for link and shared files icon-overlay. Some other modifications look for modifications for commentlines "soner".
I made modifications only for TShellListView. I think both component must extend, some things are not the best.
Edit3:I added images for Linux. For Linux it don't use system images, it use built in images. Better than nothing