TKIcon: a component for icon management better than Lazarus native TIcon lazarus / 39-Graphics ---------------------------------------------------------------------- alejol0 · 2010-09-26 12:44 Today I have discovered TKIcon. Until now, I was struggled against Lazarus native TIcon. TIcon  do not displays well  icons with alpha channel and puts a black background in some transparent icons.  The TKIcon  unit is a very great tool for icon handling in Lazarus and Delphi. TKIcon manages correctly the transparency and alpha channel. http://www.tkweb.eu/en/delphicomp/kicon.html Home: http://www.tkweb.eu/en/main/ Example of extracting a icon associated to a object in Windows: Put a TImage in a form and an OpenDialog or some other mechanism for obtaining a complete path and filename as a string. Pass this string to the procedure  ShowIconFromShortcutOrFile. Download the KIcon package (5_kicon_2.1.zip is the latest release). Uncompress and be sure that the files contained in the folder \source (kcontrols.pas, ksurce.pas and all files with "k" in front) are copied to your project folder. Code: [Select]unit Unit1; {$mode objfpc}{$H+} interface uses   //we need add KIcon and KGraphics   Windows,Classes, SysUtils, FileUtil, Forms, Controls,   Graphics, Dialogs, ComCtrls, ComObj, ActiveX,   StdCtrls, ExtCtrls, Menus, ShlObj, KIcon,  KGraphics ;   //ActiveX , ComObj and ShlObj needed for retrieving   // Windows desktop icon type   { TForm1 } // other code here ... Procedure ShowIconFromShortcutOrFile(FileName: String); var    KIcon1: TKIcon;    FileInfo: SHFILEINFO; Begin     try         KIcon1 := TKIcon.Create;        //This searches the Windows Desktop icon associated to       // a file or shortcut       //Other constants exist , but $100 serves for our purpose       SHGetFileInfo(PChar(FileName), 0, FileInfo, SizeOf(FileInfo), $100);          KIcon1.LoadFromHandle(FileInfo.hIcon) ;       //this shows the icon in a TImage control        Image1.Picture.Assign(KIcon1);     finally         DestroyIcon(FileInfo.hIcon);         KIcon1.Free;     end; End; //end of procedure ShowIconFromShortcutOrFile I wish to thank to tk, the programmer that have created this code.