how to use an icon in multiple places
-
Hi there I have an icon that i use as: my application's icon my notifyicon's icon and my main form's icon its a 22kb icon. now everything works fine but the size of my app increases three times! (66kb) when it should only have increased 22kb how can i fix this problem or is this something normal? VisionTec
-
Hi there I have an icon that i use as: my application's icon my notifyicon's icon and my main form's icon its a 22kb icon. now everything works fine but the size of my app increases three times! (66kb) when it should only have increased 22kb how can i fix this problem or is this something normal? VisionTec
Use only one instance of it, say from a static class:
public sealed class AppInfo
{
private AppInfo() {} // Prevent instantiation
private static Icon AppIcon; // Private field
static AppInfo() // Static constructor
{
AppIcon = new Icon(typeof(AppInfo), "App.ico");
}
}This is a basic example, but should give you the idea. You won't be able to use the same icon for the application (the icon that is at the first index in the PE/COFF executables .rsrc section), though. That's stored different than the "App.ico" (example) for which you should change the build action to "Embedded Resource".
Microsoft MVP, Visual C# My Articles