SystemIcons Class
.NET Framework 2.0
Each property of the SystemIcons class is an Icon object for Windows system-wide icons. This class cannot be inherited.
Namespace: System.Drawing
Assembly: System.Drawing (in system.drawing.dll)
Assembly: System.Drawing (in system.drawing.dll)
The following code example demonstrates how to load a bitmap from an Icon handle, using the GraphicsUnit enumeration, and the use of the Round method to draw the rectangle bounds of a bitmap.
This example is designed to be used with Windows Forms. Create a form that contains a button named Button2. Paste the code into the form and associate this method with the button's Click event.
private void Button2_Click(System.Object sender, System.EventArgs e) { Bitmap bitmap1 = Bitmap.FromHicon(SystemIcons.Hand.Handle); Graphics formGraphics = this.CreateGraphics(); GraphicsUnit units = GraphicsUnit.Point; RectangleF bmpRectangleF = bitmap1.GetBounds(ref units); Rectangle bmpRectangle = Rectangle.Round(bmpRectangleF); formGraphics.DrawRectangle(Pens.Blue, bmpRectangle); formGraphics.Dispose(); }
private void button2_Click(System.Object sender, System.EventArgs e)
{
Bitmap bitmap1 = Bitmap.FromHicon(SystemIcons.get_Hand().get_Handle());
Graphics formGraphics = this.CreateGraphics();
GraphicsUnit units = GraphicsUnit.Point;
RectangleF bmpRectangleF = bitmap1.GetBounds(units);
Rectangle bmpRectangle = Rectangle.Round(bmpRectangleF);
formGraphics.DrawRectangle(Pens.get_Blue(), bmpRectangle);
formGraphics.Dispose();
} //button2_Click
Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.