Geralds Thought Shed

Gedanken zu .Net, C#, Java, Windows, Linux, Mobile-Life und mehr….

Mit ‘Bitmap’ verschlagwortete Einträge

C# – Bitmap (jpg, png) als Icon für das NotifyIcon-Element

Verfasst von Gerald Huber am Samstag, 5. Januar 2008

Ich wurde gestern wieder einmal gefragt, wie man ein NotifyIcon-Element bei .NET ein Bitmap-Image als Icon übergeben kann.

Eigentlich ist es ganz einfach, wenn man es weiß ;-)

// Here is our notifyIcon
NotifyIcon myNotifyIcon;
this.myNotifyIcon = new NotifyIcon(this.components);

// now we convert the Bitmap image in an icon
Icon icon = Icon.FromHandle(((Bitmap)Image.FromFile("Resources/Settings.png")).GetHicon());
this.myNotifyIcon.Icon = icon;

Veröffentlicht in .NET | Verschlagwortet mit : , , , | 1 Kommentar »