public DrawIcon ( |
||
icon | ||
targetRect | ||
return | void |
Icon myIcon = new Icon("myicon.ico"); Graphics g = this.CreateGraphics(); g.DrawIcon(myIcon, new Rectangle(10, 10, 50, 50));
IntPtr hIcon = LoadIcon(IntPtr.Zero, "myicon.ico"); Icon myIcon = Icon.FromHandle(hIcon); Graphics g = this.CreateGraphics(); g.DrawIcon(myIcon, new Rectangle(10, 10, 50, 50));This example uses a Win32 API function, LoadIcon, to load an icon from a file. We then create a new Icon instance from the returned handle and use the DrawIcon method to draw the icon on screen. Package/library: The DrawIcon method is part of the .NET Framework's System.Drawing library.
public DrawIcon ( |
||
icon | ||
targetRect | ||
return | void |