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 Forms 使用,而且需要 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
適用於
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應