7.6. Working with Icons

The Icon class represents a Windows icon, which is a small transparent bitmap. Just like the Bitmap class, this class is inherited from the Image class.

An application can create an Icon object from a stream, string, icon, icon file, or type by using the Icon class constructors with the size of the icon as an optional parameter. The Icon class provides four read-only properties—Handle, Height, Size, and Width—which return a window handle to the icon, height, size, and width of an icon, respectively.

Listing 7.21 creates an Icon object from an icon file and sets the icon of a form using the Form class’s Icon property.

Listing 7.21. Creating an icon and setting a form’s Icon property
 private void Form1_Load(object sender, ...

Get Graphics Programming with GDI+ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.