This is how to load an Icon from an embedded resource and then use it to change a task bar notification icon.
Firstly embed the icons as a resource. Don't forget to change the Build Action of each icon to "Embedded Resource"
Declare these variables
private System.Drawing.Icon icnNormal;
private System.Drawing.Icon icnAlert;
Put this in your Form_Load() method
System.IO.Stream st;
System.Reflection.Assembly a = System.Reflection.Assembly.GetExecutingAssembly ();
st = a.GetManifestResourceStream ("{{{YourAppName}}}.Resources.App.ico");
icnNormal = new System.Drawing.Icon (st);
st = a.GetManifestResourceStream ("{{{YourAppName}}}.Resources.arrow-up_32.ico");
icnAlert = new System.Drawing.Icon (st);
Replace {{{YourAppName}}} with the name of your application
To use the icon
notifyIcon1.Icon = icnAlert;
No comments:
Post a Comment