Win XP Icons

IcingDeath

Freshman
Joined
Feb 2, 2005
Messages
31
help :eek: !!
Whats the best practice for icons in .net? Like I was expecting it would support antialliased XP icons but it doesnt! Is there a best practice in order to force the listview to get them without distorting them? (It puts a black shade around them... looks terrible). I converted the icons to bitmaps and they look better but the main problem is that they dont really support transparency since the imagelist messes them up. I converted them using print screen (wow! lol) so i got em as windows drawed them on explorer file list.
 
IcingDeath said:
help :eek: !!
Whats the best practice for icons in .net? Like I was expecting it would support antialliased XP icons but it doesnt! Is there a best practice in order to force the listview to get them without distorting them? (It puts a black shade around them... looks terrible). I converted the icons to bitmaps and they look better but the main problem is that they dont really support transparency since the imagelist messes them up. I converted them using print screen (wow! lol) so i got em as windows drawed them on explorer file list.

I`ve just found the solution to this problem this morning.
You need to get a handle of the system image list with SHGetFileInfo
(more information in MSDN), and force the listview to get the imagelist from the system image list handle with SendMessage and LVM_SETIMAGELIST

it shoul look something like this:

....

private System.Windows.Forms.ListView lstViewLeft;
IntPtr hImgSmall; //the handle to the system image list
SHFILEINFO shinfo = new SHFILEINFO();
//SHFILEINFO is not defined if you use C# like me
//
//set the listview imagelist to system`s image list (1 is for SmallImageList)
SendMessage(this.lstViewLeft.Handle, LVM_SETIMAGELIST, 1 ,(UInt32)hImgSmall);

//and then get the icon index on every file you want with
SHGetFileInfo(FilePath, 0, ref shinfo,(uint)Marshal.SizeOf(shinfo),SHGFI_SYSICONINDEX | SHGFI_SMALLICON );


the item you add in the imagelist hould hade the image index
shinfo.iIcon

I`me just cutting and pasting code from my program so search for help on the methods and data structures yourself to understand how they work.
If you don`t use the system imagelist I don`t know any other way to get the icons that are not distorted.
 
Convert your icons to .PNG format (Microangelo Studio, for one, can do this).
PNG supports transparency.
PNG files are almost always smaller than ICO files - an added bonus.

(If you do so, just make sure to save the .PNG file using transparency).
 
Back
Top