ShellBrowser Delphi Components Documentation
ContentsIndexHome
PreviousUpNext
ShellControls.TJamShellList.CustomIcons

If activated, the TGlobalCustomIconHandler will be called, that allows you to set custom icons tree nodes instead of using the system icons. If false, the event is not called for items in this instance.

Syntax
Pascal
property CustomIcons;

The following example is taken from JamExplorer and shows a small samples implementation for a TJamShellList and TJamShellTree.

unit CustomIconsExample;
interface
uses Vcl.Forms, ShellControls, Vcl.Controls, Jam.Shell.Controls.Types;

type
  TMainForm = class(TForm)
      CustomSmallImages: TImageList; //contains the custom icons. In newer Delphi version a TVirtualImageList can be used instead.
      ShellList: TJamShellList;
      ShellTree: TJamShellTree;
      procedure FormCreate(Sender: TObject);
  private
      fCustomIconPath: string;
      procedure GetCustomIcon(Sender: TObject; const pPath: string; var pEventArgs: TCustomizeIconEventArgs);



  end;

implementation
uses System.SysUtils, ShellBrowser;

procedure TMainForm.FormCreate(Sender: TObject);
begin
  //registers GetCustomIcon as global eventhandler.
   TGlobalCustomIconHandler.SetOnGetCustomIconForPath(GetCustomIcon)

  //activates the eventhandler for the ShellList and the ShellTree
  ShellTree.CustomIcons := true;
  ShellList.CustomIcons := true;
end;

procedure TMainForm.GetCustomIcon(Sender: TObject; const pPath: string; var pEventArgs: TCustomizeIconEventArgs);
begin
  if (Sender = ShellList) then begin
    if (Uppercase(ExtractFileExt(pPath)) = '.TXT') then begin
      pEventArgs.ImageList := CustomSmallImages;
      pEventArgs.ImageIndex := 0;
    end;
  end
  else if (Sender = ShellTree) then begin
    if SamePath(pPath, fCustomIconPath) then begin
      pEventArgs.ImageList := CustomSmallImages;
      pEventArgs.ImageIndex := 1;
    end;
  end;

end;



end.