Graphics.DrawIcon 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
지정된 Icon에 의해 나타나는 이미지를 지정된 좌표에 그립니다.
오버로드
DrawIcon(Icon, Rectangle) | |
DrawIcon(Icon, Int32, Int32) |
지정된 Icon에 의해 나타나는 이미지를 지정된 좌표에 그립니다. |
DrawIcon(Icon, Rectangle)
- Source:
- Graphics.cs
- Source:
- Graphics.cs
- Source:
- Graphics.cs
public:
void DrawIcon(System::Drawing::Icon ^ icon, System::Drawing::Rectangle targetRect);
public void DrawIcon (System.Drawing.Icon icon, System.Drawing.Rectangle targetRect);
member this.DrawIcon : System.Drawing.Icon * System.Drawing.Rectangle -> unit
Public Sub DrawIcon (icon As Icon, targetRect As Rectangle)
매개 변수
- targetRect
- Rectangle
표시 화면에 결과로 나타날 이미지의 위치와 크기를 지정하는 Rectangle 구조체입니다. icon
매개 변수에 포함된 이미지는 이 사각형 영역의 크기에 맞게 크기가 조정됩니다.
예외
icon
이(가) null
인 경우
예제
다음 코드 예제는 Windows Forms 사용하도록 설계되었으며 이벤트 처리기의 Paint 매개 변수인 가 필요합니다.PaintEventArgse
코드는 다음 작업을 수행합니다.
예제 폴더의 표준 Windows 아이콘 파일 SampIcon.ico 아이콘을 만듭니다.
아이콘을 그릴 사각형을 만듭니다.
화면에 아이콘을 그립니다.
사각형의 위치는 화면에서 아이콘을 찾고 사각형의 크기에 따라 그려진 아이콘의 크기가 결정됩니다.
private:
void DrawIconRectangle( 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->DrawIcon( newIcon, rect );
}
private void DrawIconRectangle(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.DrawIcon(newIcon, rect);
}
Private Sub DrawIconRectangle(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.DrawIcon(newIcon, rect)
End Sub
적용 대상
DrawIcon(Icon, Int32, Int32)
- Source:
- Graphics.cs
- Source:
- Graphics.cs
- Source:
- Graphics.cs
지정된 Icon에 의해 나타나는 이미지를 지정된 좌표에 그립니다.
public:
void DrawIcon(System::Drawing::Icon ^ icon, int x, int y);
public void DrawIcon (System.Drawing.Icon icon, int x, int y);
member this.DrawIcon : System.Drawing.Icon * int * int -> unit
Public Sub DrawIcon (icon As Icon, x As Integer, y As Integer)
매개 변수
- x
- Int32
그려지는 이미지의 왼쪽 위 모퉁이에 대한 X 좌표입니다.
- y
- Int32
그려지는 이미지의 왼쪽 위 모퉁이에 대한 Y 좌표입니다.
예외
icon
이(가) null
인 경우
예제
다음 코드 예제는 Windows Forms 사용하도록 설계되었으며 이벤트 처리기의 Paint 매개 변수인 가 필요합니다.PaintEventArgse
코드는 다음 작업을 수행합니다.
예제 폴더의 표준 Windows 아이콘 파일 SampIcon.ico 아이콘을 만듭니다.
아이콘을 그릴 왼쪽 위 모서리의 좌표를 만듭니다.
화면에 아이콘을 그립니다.
그려진 아이콘의 크기가 조정되지 않습니다.
private:
void DrawIconInt( PaintEventArgs^ e )
{
// Create icon.
System::Drawing::Icon^ newIcon = gcnew System::Drawing::Icon( "SampIcon.ico" );
// Create coordinates for upper-left corner of icon.
int x = 100;
int y = 100;
// Draw icon to screen.
e->Graphics->DrawIcon( newIcon, x, y );
}
private void DrawIconInt(PaintEventArgs e)
{
// Create icon.
Icon newIcon = new Icon("SampIcon.ico");
// Create coordinates for upper-left corner of icon.
int x = 100;
int y = 100;
// Draw icon to screen.
e.Graphics.DrawIcon(newIcon, x, y);
}
Private Sub DrawIconInt(ByVal e As PaintEventArgs)
' Create icon.
Dim newIcon As New Icon("SampIcon.ico")
' Create coordinates for upper-left corner of icon.
Dim x As Integer = 100
Dim y As Integer = 100
' Draw icon to screen.
e.Graphics.DrawIcon(newIcon, x, y)
End Sub
적용 대상
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기