Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


ID: 590, Converting a TIcon to a TBitmap

by Anders Melander Email: Anonymous


Download Details
FTP  download also available 0 bytes
CDN Login Required to Download. (You will be redirected to the login page if you click on the Download Link)
To download this, you must have registered:
A free membership

For Delphi, Version 3.0  to 4.0 16 downloads
Copyright: No significant restrictions


Size: 0 bytes
Updated on Wed, 12 May 1999 00:00:00 GMT
Originally uploaded on Wed, 12 May 1999 00:00:00 GMT
Description
Q: How do I convert an icon to a bitmap?

A: The following procedure converts a color icon (TIcon) to a bitmap (TBitmap).
Transparent and monochrome icons are not handled.

uses
Windows;

procedure Icon2Bitmap(const Icon: TIcon; Bitmap: TBitmap);
var
TempBitmap: TBitmap;
IconInfo: TIconInfo;
begin
// Retrieve icon data
if (not GetIconInfo(Icon.Handle, IconInfo)) then
exit;

TempBitmap := TBitmap.Create;
try
// Borrow the icon bitmap handle and assign it to a TBitmap
TempBitmap.Handle := IconInfo.hbmColor;
try
// Copy bitmap
Bitmap.Assign(TempBitmap);
// Force copy to clone handle
Bitmap.Handle;
finally
// Give the bitmap handle back to the icon
TempBitmap.ReleaseHandle;
end;
finally
TempBitmap.Free;
end;
end;

   Latest Comments  View All Add New

Move mouse over comment to see the full text

Server Response from: ETNACDC03