You are hereconvert a HIcon to tbitmap

convert a HIcon to tbitmap


By liuzg2 - Posted on 15 July 2009

this is example 

 

Many Windows API functions return a HIcon value (handle to Icon). Here's how to "convert" a HIcon to TIcon (object)

For example, when using ExtractIcon to get icon from file, the resulting value is of the HICON type.

The answer is: Create a TIcon object and assign the handle received from the ExtractIcon function to the TIcon.Handle property. If you want a bitmap, create a TBitmap and draw the icon on the bitmap's canvas. Be sure to Free the TIcon object when no longer needed.

~~~~~~~~~~~~~~~~~~~~~~~~~
var
  MyIcon:TIcon;
  icoHandle: HIcon;
begin
  MyIcon:=TIcon.Create;
  try
   icoHandle := ExtractIcon(application.handle,'c:\windows\explorer.exe', 0) ;
   MyIcon.Handle:=icoHandle;
   Image1.Picture.Icon:=MyIcon;
  finally
   MyIcon.free;
  end;
end;

 

 

 

but  how to  cover to timage