zoukankan      html  css  js  c++  java
  • Polygon

    用当前的笔绘制一个由两个或多个点(顶点)连接的多边形。

    BOOL Polygon(
       LPPOINT lpPoints,
       int nCount 
    );

    lpPoints

    指向一个指定多边形顶点的点。数组中的每一点都是一个点结构或一个CPoint对象。

     

    nCount

    指定数组中顶点的数量。

    返回值

    如果函数成功,则非零;否则0。

     1 void CDCView::DrawPolygon(CDC* pDC)
     2 {
     3    // find the client area
     4    CRect rect;
     5    GetClientRect(rect);
     6 
     7    // draw with a thick blue pen
     8    CPen penBlue(PS_SOLID, 5, RGB(0, 0, 255));
     9    CPen* pOldPen = pDC->SelectObject(&penBlue);
    10 
    11    // and a solid red brush
    12    CBrush brushRed(RGB(255, 0, 0));
    13    CBrush* pOldBrush = pDC->SelectObject(&brushRed);
    14 
    15    // Find the midpoints of the top, right, left, and bottom
    16    // of the client area. They will be the vertices of our polygon.
    17    CPoint pts[4];
    18    pts[0].x = rect.left + rect.Width()/2;
    19    pts[0].y = rect.top;
    20 
    21    pts[1].x = rect.right;
    22    pts[1].y = rect.top + rect.Height()/2;
    23 
    24    pts[2].x = pts[0].x;
    25    pts[2].y = rect.bottom;
    26 
    27    pts[3].x = rect.left;
    28    pts[3].y = pts[1].y;
    29 
    30    // Calling Polygon() on that array will draw three lines
    31    // between the points, as well as an additional line to
    32    // close the shape--from the last point to the first point
    33    // we specified.
    34    pDC->Polygon(pts, 4);
    35 
    36    // Put back the old objects.
    37    pDC->SelectObject(pOldPen);
    38    pDC->SelectObject(pOldBrush);
    39 }
  • 相关阅读:
    设计模式(18)>职责链模式 小强斋
    设计模式(17)>中介者模式 小强斋
    设计模式(16)>原型模式 小强斋
    设计模式(20)>状态模式 小强斋
    设计模式(15)>桥接模式 小强斋
    设计模式(18)>职责链模式 小强斋
    堆栈的工作原理
    掌握udev
    Qt Model/View 学习笔记 (七)
    Qt Model/View 学习笔记 (六)
  • 原文地址:https://www.cnblogs.com/qiwu1314/p/9778055.html
Copyright © 2011-2022 走看看