다음을 통해 공유


Pen::GetWidth 메서드(gdipluspen.h)

Pen::GetWidth 메서드는 이 Pen 개체에 대해 현재 설정된 너비를 가져옵니다.

구문

REAL GetWidth();

반환 값

형식: REAL

이 메서드는 이 Pen 개체의 너비를 나타내는 실제 숫자를 반환합니다.

설명

그래픽 개체의 그리기 메서드 중 하나에 펜의 주소를 전달하는 경우 펜 스트로크의 너비는 Graphics 개체에 지정된 측정 단위에 따라 달라집니다. 측정의 기본 단위는 UnitPixel로, Unit 열거형의 요소입니다.

예제

다음 예제에서는 지정된 너비의 Pen 개체를 만들고 선을 그립니다. 그런 다음, 코드는 펜의 너비를 가져오고, 첫 번째 펜의 너비에 따라 두 번째 펜을 만들고, 두 번째 선을 그립니다.

VOID Example_GetWidth(HDC hdc)
{
   Graphics graphics(hdc);

   // Create a pen with a width of 15, and 
   // use that pen to draw a line.
   Pen pen(Color(255, 0, 0, 255), 15);
   graphics.DrawLine(&pen, 20, 20, 200, 100);

   // Get the width of the pen.
   REAL width = pen.GetWidth();

   // Create another pen that has the same width.
   Pen pen2(Color(255, 0, 255, 0), width);

   // Draw a second line.
   graphics.DrawLine(&pen2, 20, 60, 200, 140);
}

요구 사항

   
지원되는 최소 클라이언트 Windows XP, Windows 2000 Professional [데스크톱 앱만 해당]
지원되는 최소 서버 Windows 2000 Server[데스크톱 앱만]
대상 플랫폼 Windows
헤더 gdipluspen.h(Gdiplus.h 포함)
라이브러리 Gdiplus.lib
DLL Gdiplus.dll

참고 항목

펜::SetWidth

펜, 선 및 사각형

펜 너비 및 맞춤 설정