1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| void CFoobar::DrawCross(CDC *pDC, int x, int y, MYCOLOR color, bool bDraw) { CPen *oldPen = pDC->SelectObject(&m_pen[GRAY]);//保存DC原始画笔 int radius = 22; int basegap = 4; int rectradius = radius- basegap; int rectgap = 10; if (bDraw) { pDC->SelectObject(&m_pen[color]); } else { pDC->SelectObject(&m_pen[WHITE]); } // 十字形,上、下、左、右 Line(pDC, color, x - radius, y, x - basegap, y); Line(pDC, color, x + basegap, y, x + radius, y); Line(pDC, color, x, y - radius, x, y - basegap); Line(pDC, color, x, y + basegap, x, y + radius);
// 四边角,逆时针画 Line(pDC, color, x - rectgap, y - rectradius, x - rectradius, y - rectradius); Line(pDC, color, x - rectradius, y - rectradius, x - rectradius, y - rectgap); Line(pDC, color, x - rectradius, y + rectgap, x - rectradius, y + rectradius); Line(pDC, color, x - rectradius, y + rectradius, x - rectgap, y + rectradius); Line(pDC, color, x + rectgap, y + rectradius, x + rectradius, y + rectradius); Line(pDC, color, x + rectradius, y + rectradius, x + rectradius, y + rectgap); Line(pDC, color, x + rectradius, y - rectgap, x + rectradius, y - rectradius); Line(pDC, color, x + rectradius, y - rectradius, x + rectgap, y - rectradius);
pDC->SelectObject(oldPen); //回复DC原画笔 }
|