by Jim
Oct 28, 2006 8:14 AM
The tray icon that I created for my application looked like a dog next to all the other beautiful icons in my system tray. Look at the rough edges on the smiley face.
At first I thought that windows was choosing the wrong size icon for the system tray. My icon file has 32x32 and 16x16 icons, and windows was using the correct one in every other situation. Then I realized that the problem was loading the icon from my exe's resources. I was doing this:
mIcons(0) = New Icon( _
GetType(MainForm).Assembly.GetManifestResourceStream("EventWatcher.EventWatcher.ico"))
When I should have been doing this:
mIcons(0) = New Icon( _
GetType(MainForm).Assembly.GetManifestResourceStream("EventWatcher.EventWatcher.ico"), _
New Size(16, 16))
The .NET icon object doesn't load the whole icon file, just one icon. So Windows never got a chance to choose the right one. By default, it was loading the 32x32 icon, probably just because it was first in the list.