代码实现:
void CCGDrawingView::Rectangle(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4, COLORREF color,CDC* pDC) {CPen redPen(PS_SOLID, 1, color);CBrush redBursh(color);CPen* pOldPen = pDC->SelectObject(&redPen);CBrush* pOLdBrush = pDC->SelectObject(&redBursh);pDC->MoveTo(x1, y1);pDC->LineTo(x2, y2);pDC->LineTo(x3, y3);pDC->LineTo(x4, y4);pDC->LineTo(x1, y1);}