Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

  • 2 months later...
Posted
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.

Posted

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).

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...