Graphics.DrawIconUnstretched(Icon, Rectangle) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
在不缩放图像的情况下绘制由指定 Icon 表示的图像。
public:
void DrawIconUnstretched(System::Drawing::Icon ^ icon, System::Drawing::Rectangle targetRect);
public void DrawIconUnstretched (System.Drawing.Icon icon, System.Drawing.Rectangle targetRect);
member this.DrawIconUnstretched : System.Drawing.Icon * System.Drawing.Rectangle -> unit
Public Sub DrawIconUnstretched (icon As Icon, targetRect As Rectangle)
参数
例外
icon
null
。
示例
下面的代码示例设计用于 Windows 窗体,它需要 PaintEventArgse
,这是 Paint 事件处理程序的参数。 该代码执行以下操作:
从示例文件夹中的标准 Windows 图标文件创建图标SampIcon.ico。
创建一个要在其中绘制图标的矩形。
将图标绘制到屏幕。
矩形的位置将定位屏幕上的图标,并且绘制的图标未缩放且未调整。
private:
void DrawIconUnstretchedRectangle( PaintEventArgs^ e )
{
// Create icon.
System::Drawing::Icon^ newIcon = gcnew System::Drawing::Icon( "SampIcon.ico" );
// Create rectangle for icon.
Rectangle rect = Rectangle(100,100,200,200);
// Draw icon to screen.
e->Graphics->DrawIconUnstretched( newIcon, rect );
}
private void DrawIconUnstretchedRectangle(PaintEventArgs e)
{
// Create icon.
Icon newIcon = new Icon("SampIcon.ico");
// Create rectangle for icon.
Rectangle rect = new Rectangle(100, 100, 200, 200);
// Draw icon to screen.
e.Graphics.DrawIconUnstretched(newIcon, rect);
}
Private Sub DrawIconUnstretchedRectangle(ByVal e As PaintEventArgs)
' Create icon.
Dim newIcon As New Icon("SampIcon.ico")
' Create rectangle for icon.
Dim rect As New Rectangle(100, 100, 200, 200)
' Draw icon to screen.
e.Graphics.DrawIconUnstretched(newIcon, rect)
End Sub