Thanks,
I just tried it but it didn't work
Main Topics
Browse All TopicsI have a listbox associated with an ImageList.
If I add icons to an ImageList at designtime and then allocate them to the listbox items at runtime, they display perfectly.
However, if I populate the ImageList at runtime, using:
SHGetFileInfo(PChar(FileNa
and then allocate them to the listbox, the icons display incorrectly with a black background.
Incidentally, if I allocate the system small image list to my ImageList, using:
SHGetFileInfo('', 0, FileInfo, SizeOf(FileInfo), SHGFI_SYSICONINDEX or SHGFI_SMALLICON)
and then retrieve the imageindex, using:
SHGetFileInfo(PChar(AFile)
Result := SFI.iIcon;
they also display correctly. The reason I can't just use the system small image list is that I want to add other icons to it.
Any ideas what I am doing wrong?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Try this:
icon:=TIcon.Create;
icon.Handle:=fileInfo.hIco
bitmap := TBitmap.Create;
try
bitmap.Height := icon.Height;
bitmap.Width := icon.Width;
bitmap.Canvas.Draw(0, 0, icon);
images.AddMasked(bitmap, clDefault);
finally
bitmap.free;
icon.Free;
end;
But this is not resolved this problem, because there will be white background color.
If TIcon consists with two bitmaps, main and mask.
It look like that problem in this
Try other test:
...
icon:=TIcon.Create;
icon.Handle:=fileInfo.hIco
largeImages.AddIcon(icon);
GetIconInfo(icon.Handle, iconInfo);
bitmap := TBitmap.Create;
clrBmp := TBitmap.Create;
maskBmp := TBitmap.Create;
try
bitmap.Height := icon.Height;
bitmap.Width := icon.Width;
bitmap.Canvas.Draw(0, 0, icon);
largeImages.AddMasked(bitm
clrBmp.Handle := iconInfo.hbmColor;
maskBmp.Handle := iconInfo.hbmMask;
maskBmp.PixelFormat := pf1bit;
largeImages.AddMasked(clrB
largeImages.AddMasked(clrB
largeImages.AddMasked(mask
largeImages.AddMasked(mask
finally
bitmap.free;
clrBmp.free;
maskBmp.free;
icon.Free;
end;
You can see that problem in invalid rendering main image over mask If you make screenshot and zoom it in image editor.
Thanks oraelbis
Your code did not work for me as I am using 32bpp icons, but it got me searching in the right direction and I found the answer.
Add XPManifest to project.
Create all imagelists using ImageList_Create with ILC_COLOR32 flag, as below.
procedure TfrmMain.FormCreate(Sender
var hImList: Cardinal;
begin
hImList := ImageList1.Handle;
ImageList1.Handle := ImageList_Create(16, 16, ILC_COLOR32 or ILC_MASK, ImageList1.AllocBy, ImageList1.AllocBy);
ImageList_Destroy(hImList)
end;
You need to ad commctrl to uses.
Thanks Siarhei
You really helped me out by gettings me to look in the right direction. I've created a "Points for Oraelbis question", so you can get your rewards here:
http://www.experts-exchang
Business Accounts
Answer for Membership
by: calinutzPosted on 2005-10-26 at 13:03:11ID: 15166070
Did you try to set the drawing style of the imagestyle to dsTransparent?