Home  |  Delphi .net Home  |  System.Drawing.Graphics  |  DrawIcon Method
DrawIcon  
Method  
Draws an icon onto the graphics canvas
Graphics Class
System.Drawing NameSpace
CF1.  Procedure DrawIcon ( Icon:System.Drawing.IconIcon : System.Drawing.Icon; X : Integer; Y : Integer ; ) ;
NotCF2.  Procedure DrawIcon ( Icon:System.Drawing.IconIcon : System.Drawing.Icon; Rectangle : System.Drawing.Rectangle; ) ;
CF : Methods with this mark are Compact Framework Compatible
Description
The DrawIcon method draws the specified Icon object at either the specified X,Y coordinates at 1:1 scaling, or stretched to fit exactly in the specified Rectangle.
Microsoft MSDN Links
System.Drawing
System.Drawing.Graphics
 
 
Drawing a small Icon at 1:1 scaling
procedure TWinForm.TWinForm_Paint(sender: System.Object;
                                  e: System.Windows.Forms.PaintEventArgs);
var
  Icon : System.Drawing.Icon;
begin
  // This example uses a 16 by 16 Icon
  Icon := System.Drawing.Icon.Create('SmallLogo.ico');
  e.Graphics.DrawIcon(Icon, 2, 2);
end;
Show full unit code
  
Stretching this same icon to twice its width
procedure TWinForm.TWinForm_Paint(sender: System.Object;
                                  e: System.Windows.Forms.PaintEventArgs);
var
  Icon : System.Drawing.Icon;
begin
  // This example uses a 16 by 16 Icon
  Icon := System.Drawing.Icon.Create('SmallLogo.ico');
  e.Graphics.DrawIcon(Icon, Rectangle.Create(2, 2, 32, 16));
end;
Show full unit code
  
 
 
Delphi Programming © Neil Moffatt All rights reserved.  |  Contact the author