다음을 통해 공유


CDC::Polygon

현재 펜을 사용 하 여 선으로 연결 된 두 개 이상의 지점 (꼭지점)으로 구성 된 다각형을 그립니다.

BOOL Polygon( 
   LPPOINT lpPoints, 
   int nCount  
);

매개 변수

  • lpPoints
    다각형의 꼭지점을 지정 하는 점의 배열 가리킵니다. 배열의 각 점은 가리키고 구조 또는 CPoint 개체입니다.

  • nCount
    배열에서 꼭지점의 수를 지정합니다.

반환 값

함수가 성공 하면 0이 아닌. 그렇지 않으면 0입니다.

설명

시스템 다각형 자동으로 필요한 경우 줄에서 마지막 꼭지점에 첫 번째 그려서 닫힙니다.

현재 다각형 채우기 모드를 검색 하거나 사용 하 여 설정할 수 있는 GetPolyFillModeSetPolyFillMode 멤버 함수입니다.

예제

void CDCView::DrawPolygon(CDC* pDC)
{
   // find the client area
   CRect rect;
   GetClientRect(rect);

   // draw with a thick blue pen
   CPen penBlue(PS_SOLID, 5, RGB(0, 0, 255));
   CPen* pOldPen = pDC->SelectObject(&penBlue);

   // and a solid red brush
   CBrush brushRed(RGB(255, 0, 0));
   CBrush* pOldBrush = pDC->SelectObject(&brushRed);

   // Find the midpoints of the top, right, left, and bottom 
   // of the client area. They will be the vertices of our polygon.
   CPoint pts[4];
   pts[0].x = rect.left + rect.Width()/2;
   pts[0].y = rect.top;

   pts[1].x = rect.right;
   pts[1].y = rect.top + rect.Height()/2;

   pts[2].x = pts[0].x;
   pts[2].y = rect.bottom;

   pts[3].x = rect.left;
   pts[3].y = pts[1].y;

   // Calling Polygon() on that array will draw three lines 
   // between the points, as well as an additional line to 
   // close the shape--from the last point to the first point 
   // we specified.
   pDC->Polygon(pts, 4);

   // Put back the old objects.
   pDC->SelectObject(pOldPen);
   pDC->SelectObject(pOldBrush);
}

요구 사항

헤더: afxwin.h

참고 항목

참조

CDC 클래스

계층 구조 차트

CDC::GetPolyFillMode

CDC::Polyline

CDC::PolyPolygon

CDC::SetPolyFillMode

CPoint Class

Polygon