void CHSScrollBar::DrawBorder( CDC* pDC ) { CPen Pen; Pen.CreatePenIndirect(&m_logpen.GetPen(HsLOGPEN::hor)); CPen* pOldPen; pOldPen = pDC->SelectObject(&Pen); // 画上边框 pDC->MoveTo(m_rect.left, m_rect.top); pDC->LineTo(m_rect.right, m_rect.top); // 画下边框 pDC->MoveTo(m_rect.left, m_rect.bottom); pDC->LineTo(m_rect.right, m_rect.bottom); Pen.DeleteObject(); Pen.CreatePenIndirect(&m_logpen.GetPen(HsLOGPEN::ver)); pDC->SelectObject(&Pen); // 画左边框 pDC->MoveTo(m_rect.left, m_rect.top); pDC->LineTo(m_rect.left, m_rect.bottom); // 画右边框 pDC->MoveTo(m_rect.right, m_rect.top); pDC->LineTo(m_rect.right, m_rect.bottom); pDC->SelectObject(pOldPen); Pen.DeleteObject(); }
void CArc::Draw(CDC *pDC) { if(m_lStatus!=ST_NOMAL) return; LOGPEN tPen=m_pen; UPtoLP(m_pen.lopnWidth.x,m_pen.lopnWidth.y,&tPen.lopnWidth.x,&tPen.lopnWidth.y); CPen pen; pen.CreatePenIndirect(&tPen); CPen *pOldPen=pDC->SelectObject(&pen); long x1,y1,x2,y2,x3,y3,x4,y4; x1=m_lx1; y1=m_ly1; if(m_lx1>m_lx2){ m_lx1=m_lx2; m_lx2=x1; } if(m_ly1>m_ly2){ m_ly1=m_ly2; m_ly2=y1; } UPtoLP(m_lx1,m_ly1,&x1,&y1); UPtoLP(m_lx2,m_ly2,&x2,&y2); if(m_lx3==0 && m_ly3==0 && m_lx4==0 && m_ly4==0){ m_lx4=(m_lx2+m_lx1)/2; m_ly4=m_ly2+DELTA*2; m_lx3=m_lx2+DELTA*2; m_ly3=(m_ly1+m_ly2)/2; } UPtoLP(m_lx3,m_ly3,&x3,&y3); UPtoLP(m_lx4,m_ly4,&x4,&y4); pDC->Arc(x1,y1,x2,y2,x3,y3,x4,y4); pDC->SelectObject(pOldPen); }
void CEllipse::Draw(CDC *pDC) { if(m_lStatus!=ST_NOMAL) return; LOGPEN tPen=m_pen; UPtoLP(m_pen.lopnWidth.x,m_pen.lopnWidth.y,&tPen.lopnWidth.x,&tPen.lopnWidth.y); CPen pen; pen.CreatePenIndirect(&tPen); CPen *pOldPen=pDC->SelectObject(&pen); CBrush brush; brush.CreateBrushIndirect(&m_brush); CBrush *pOldBrush=pDC->SelectObject(&brush); pDC->SetBkMode(TRANSPARENT); long x1,y1,x2,y2; x1=m_lx1; y1=m_ly1; if(m_lx1>m_lx2){ m_lx1=m_lx2; m_lx2=x1; } if(m_ly1>m_ly2){ m_ly1=m_ly2; m_ly2=y1; } UPtoLP(m_lx1,m_ly1,&x1,&y1); UPtoLP(m_lx2,m_ly2,&x2,&y2); pDC->Ellipse(x1,y1,x2,y2); pDC->SelectObject(pOldPen); pDC->SelectObject(pOldBrush); }
void CLine::Draw(CDC *pDC) { long x1,y1,x2,y2; if(m_DnyAttr.m_Linked && m_DnyAttr.m_na) { CPen *pop=(CPen*)(pDC->SelectStockObject(BLACK_PEN)); CBrush *pob=(CBrush*)(pDC->SelectStockObject(WHITE_BRUSH)); UPtoLP(m_lox1,m_loy1,&x1,&y1); UPtoLP(m_lox2,m_loy2,&x2,&y2); pDC->Rectangle(x1,y1,x2,y2); pDC->SelectObject(pop); pDC->SelectObject(pob); pDC->DrawIcon(x1,y1,ghNA); return; } if(m_DnyAttr.m_Linked && !m_DnyAttr.m_vi) return; LOGPEN tPen=m_pen; UPtoLP(m_pen.lopnWidth.x,m_pen.lopnWidth.y,&tPen.lopnWidth.x,&tPen.lopnWidth.y); CPen pen; pen.CreatePenIndirect(&tPen); CPen *pOldPen=pDC->SelectObject(&pen); UPtoLP(m_lx1,m_ly1,&x1,&y1); UPtoLP(m_lx2,m_ly2,&x2,&y2); pDC->MoveTo(x1,y1); pDC->LineTo(x2,y2); pDC->SelectObject(pOldPen); }
void CText::DrawHotPoints(CDC *pDC) { LOGPEN tLogPen; tLogPen.lopnColor=RGB(0,0,0); tLogPen.lopnStyle=PS_DOT; tLogPen.lopnWidth.x=1; CPen tPen; tPen.CreatePenIndirect(&tLogPen); CPen *pOldPen=(CPen *)pDC->SelectObject(&tPen); CBrush *pOldBrush=(CBrush *)pDC->SelectStockObject(NULL_BRUSH); pDC->SetROP2(R2_NOTXORPEN); long x1,y1,x2,y2; UPtoLP(Left()-DELTA,Top()-DELTA,&x1,&y1); UPtoLP(Right()+DELTA,Bottom()+DELTA,&x2,&y2); pDC->Rectangle(x1,y1,x2,y2); /* pDC->SelectStockObject(GRAY_BRUSH); pDC->SelectStockObject(NULL_PEN); pDC->SetROP2(R2_NOT); long x5,y5,x6,y6; UPtoLP((m_lx1+m_lx2)/2,m_ly1-DELTA,&x5,&y5); UPtoLP((m_lx1+m_lx2)/2,m_ly2+DELTA,&x6,&y6); DrawHotPoint(pDC,x5,y5); DrawHotPoint(pDC,x6,y6); */ pDC->SetROP2(R2_COPYPEN); pDC->SelectObject(pOldBrush); pDC->SelectObject(pOldPen); pDC->SelectObject(pOldBrush); }
void CDrawPoly::Draw(CDC* pDC) { ASSERT_VALID(this); CBrush brush; if (!brush.CreateBrushIndirect(&m_logbrush)) return; CPen pen; if (!pen.CreatePenIndirect(&m_logpen)) return; CBrush* pOldBrush; CPen* pOldPen; if (m_bBrush) pOldBrush = pDC->SelectObject(&brush); else pOldBrush = (CBrush*)pDC->SelectStockObject(NULL_BRUSH); if (m_bPen) pOldPen = pDC->SelectObject(&pen); else pOldPen = (CPen*)pDC->SelectStockObject(NULL_PEN); pDC->Polygon(m_points, m_nPoints); pDC->SelectObject(pOldBrush); pDC->SelectObject(pOldPen); }
// @pymethod <o PyCPen>|win32ui|CreatePen|Creates a <o PyCPen> object. /*static*/ PyObject * ui_pen_object::create (PyObject *self, PyObject *args) { int n_pen_style; int n_width; long cr_color; LOGPEN lp; if (!PyArg_ParseTuple (args, "iil", &n_pen_style, // @pyparm int|style||The pen style. &n_width, // @pyparm int|width||The pen width. &cr_color)) { // @pyparm long|color||The pen color. return NULL; } lp.lopnStyle = n_pen_style; lp.lopnWidth.x = n_width; lp.lopnWidth.y = 0; lp.lopnColor = cr_color; CPen *pPen = new CPen; if (!pPen->CreatePenIndirect (&lp)) { delete pPen; // clean up on error. RETURN_ERR ("CreatePenIndirect call failed"); } return ui_assoc_object::make (ui_pen_object::type, pPen); }
void CCell::DrawTracker(CDC *pDC) { LOGPEN tLogPen; tLogPen.lopnColor=RGB(0,0,0); tLogPen.lopnStyle=PS_DOT; tLogPen.lopnWidth.x=1; CPen tPen; tPen.CreatePenIndirect(&tLogPen); CPen *pOldPen=(CPen *)pDC->SelectObject(&tPen); CBrush *pOldBrush=(CBrush *)pDC->SelectStockObject(NULL_BRUSH); pDC->SetROP2(R2_NOTXORPEN); long x1,y1,x2,y2; switch(m_lHitTarget){ case TK_CT: break; case TK_MOV: UPtoLP(Left(),Top(),&x1,&y1); UPtoLP(Right(),Bottom(),&x2,&y2); pDC->Rectangle(x1,y1,x2,y2); MoveInCell(m_potTracker); UPtoLP(Left(),Top(),&x1,&y1); UPtoLP(Right(),Bottom(),&x2,&y2); pDC->Rectangle(x1,y1,x2,y2); break; } pDC->SetROP2(R2_COPYPEN); pDC->SelectObject(pOldPen); pDC->SelectObject(pOldBrush); }
void CLine::DrawTracker(CDC *pDC) { LOGPEN tPen=m_pen; UPtoLP(m_pen.lopnWidth.x,m_pen.lopnWidth.y,&tPen.lopnWidth.x,&tPen.lopnWidth.y); CPen pen; pen.CreatePenIndirect(&tPen); CPen *pOldPen=pDC->SelectObject(&pen); // CPen *pOldPen=(CPen *)pDC->SelectStockObject(BLACK_PEN); pDC->SetROP2(R2_NOTXORPEN); long x1,y1,x2,y2; UPtoLP(m_lx1,m_ly1,&x1,&y1); UPtoLP(m_lx2,m_ly2,&x2,&y2); pDC->MoveTo(x1,y1); pDC->LineTo(x2,y2); switch(m_lHitTarget) { case TK_LT: m_lx1=m_potTracker.x; m_ly1=m_potTracker.y; UPtoLP(m_lx1,m_ly1,&x1,&y1); pDC->MoveTo(x1,y1); pDC->LineTo(x2,y2); break; case TK_RB: m_lx2=m_potTracker.x; m_ly2=m_potTracker.y; UPtoLP(m_lx2,m_ly2,&x2,&y2); pDC->MoveTo(x1,y1); pDC->LineTo(x2,y2); break; case TK_MOV: m_lx1+=m_potTracker.x; m_ly1+=m_potTracker.y; m_lx2+=m_potTracker.x; m_ly2+=m_potTracker.y; UPtoLP(m_lx1,m_ly1,&x1,&y1); UPtoLP(m_lx2,m_ly2,&x2,&y2); pDC->MoveTo(x1,y1); pDC->LineTo(x2,y2); break; } pDC->SetROP2(R2_COPYPEN); pDC->SelectObject(pOldPen); }
void CLine::DrawHotPoints(CDC *pDC) { LOGPEN tPen=m_pen; UPtoLP(m_pen.lopnWidth.x,m_pen.lopnWidth.y,&tPen.lopnWidth.x,&tPen.lopnWidth.y); CPen pen; pen.CreatePenIndirect(&tPen); CPen *pOldPen=pDC->SelectObject(&pen); CBrush *pOldBrush=(CBrush *)pDC->SelectStockObject(GRAY_BRUSH); pDC->SetROP2(R2_NOT); long x1,y1,x2,y2; UPtoLP(m_lx1,m_ly1,&x1,&y1); UPtoLP(m_lx2,m_ly2,&x2,&y2); DrawHotPoint(pDC,x1,y1); DrawHotPoint(pDC,x2,y2); pDC->SetROP2(R2_COPYPEN); pDC->SelectObject(pOldBrush); pDC->SelectObject(pOldPen); }
void CSelectObject::DrawTracker(HDC hDC, TrackerState state, BOOL bDrawSelectTool) { BOOL bRet = FALSE; CDCHandle dc(hDC); LOGPEN logPen; logPen.lopnStyle = PS_DOT; logPen.lopnColor = RGB(0, 0, 0); logPen.lopnWidth.x = 1; logPen.lopnWidth.y = 1; CPen pen; API_VERIFY(NULL != pen.CreatePenIndirect(&logPen)); CBrushHandle pOldBrush; CPenHandle pOldPen; pOldBrush = dc.SelectStockBrush(NULL_BRUSH); if (m_bPen) { pOldPen = dc.SelectPen(pen); } else { pOldPen = dc.SelectStockPen(NULL_PEN); } //ATLTRACE(_T("DrawTracker top %d btn %d left %d right %d \n"), m_position.top, m_position.bottom, m_position.left, m_position.right); //draw on device units CRect rect = m_position; //ATLTRACE(_T("DrawTracker DocToClient top %d btn %d left %d right %d \n"), m_position.top, m_position.bottom, m_position.left, m_position.right); m_pDrawCanvas->DocToClient(&rect); //ATLTRACE(_T("DrawTracker DocToClient top %d btn %d left %d right %d \n"), rect.top, rect.bottom, rect.left, rect.right); HBRUSH hOldBrush = dc.SelectStockBrush(NULL_BRUSH); dc.Rectangle(rect); dc.SelectBrush(hOldBrush); dc.SelectPen(pOldPen); CDrawObject::DrawTracker(hDC, state, bDrawSelectTool); }
void CCell::DrawHotPoints(CDC *pDC) { LOGPEN tLogPen; tLogPen.lopnColor=RGB(0,0,0); tLogPen.lopnStyle=PS_DOT; tLogPen.lopnWidth.x=1; CPen tPen; tPen.CreatePenIndirect(&tLogPen); CPen *pOldPen=(CPen *)pDC->SelectObject(&tPen); CBrush *pOldBrush=(CBrush *)pDC->SelectStockObject(NULL_BRUSH); pDC->SetROP2(R2_NOTXORPEN); long x1,y1,x2,y2; UPtoLP(Left()-DELTA,Top()-DELTA,&x1,&y1); UPtoLP(Right()+DELTA,Bottom()+DELTA,&x2,&y2); pDC->Rectangle(x1,y1,x2,y2); pDC->SetROP2(R2_COPYPEN); pDC->SelectObject(pOldBrush); pDC->SelectObject(pOldPen); pDC->SelectObject(pOldBrush); }
void CArc::DrawTracker(CDC *pDC) { LOGPEN tPen=m_pen; UPtoLP(m_pen.lopnWidth.x,m_pen.lopnWidth.y,&tPen.lopnWidth.x,&tPen.lopnWidth.y); CPen pen; pen.CreatePenIndirect(&tPen); CPen *pOldPen=pDC->SelectObject(&pen); CBrush *pOldBrush=(CBrush *)pDC->SelectStockObject(NULL_BRUSH); pDC->SetROP2(R2_NOTXORPEN); long x1,y1,x2,y2,x3,y3,x4,y4; UPtoLP(m_lx1,m_ly1,&x1,&y1); UPtoLP(m_lx2,m_ly2,&x2,&y2); UPtoLP(m_lx3,m_ly3,&x3,&y3); UPtoLP(m_lx4,m_ly4,&x4,&y4); //pDC->Chord(x1,y1,x2,y2,x3,y3,x4,y4); pDC->Arc(x1,y1,x2,y2,x3,y3,x4,y4); switch(m_lHitTarget){ case TK_LT: m_lx1=m_potTracker.x; m_ly1=m_potTracker.y; UPtoLP(m_lx1,m_ly1,&x1,&y1); pDC->Arc(x1,y1,x2,y2,x3,y3,x4,y4); break; case TK_LB: m_lx1=m_potTracker.x; m_ly2=m_potTracker.y; UPtoLP(m_lx1,m_ly2,&x1,&y2); pDC->Arc(x1,y1,x2,y2,x3,y3,x4,y4); break; case TK_RT: m_lx2=m_potTracker.x; m_ly1=m_potTracker.y; UPtoLP(m_lx2,m_ly1,&x2,&y1); pDC->Arc(x1,y1,x2,y2,x3,y3,x4,y4); break; case TK_RB: m_lx2=m_potTracker.x; m_ly2=m_potTracker.y; UPtoLP(m_lx2,m_ly2,&x2,&y2); pDC->Arc(x1,y1,x2,y2,x3,y3,x4,y4); break; case TK_LM: m_lx1=m_potTracker.x; UPtoLP(m_lx1,m_lx1,&x1,0); pDC->Arc(x1,y1,x2,y2,x3,y3,x4,y4); break; case TK_RM: m_lx2=m_potTracker.x; UPtoLP(m_lx2,m_lx2,&x2,0); pDC->Arc(x1,y1,x2,y2,x3,y3,x4,y4); break; case TK_TM: m_ly1=m_potTracker.y; UPtoLP(m_ly1,m_ly1,0,&y1); pDC->Arc(x1,y1,x2,y2,x3,y3,x4,y4); break; case TK_BM: m_ly2=m_potTracker.y; UPtoLP(m_ly2,m_ly2,0,&y2); pDC->Arc(x1,y1,x2,y2,x3,y3,x4,y4); break; case TK_MOV: m_lx1+=m_potTracker.x; m_ly1+=m_potTracker.y; m_lx2+=m_potTracker.x; m_ly2+=m_potTracker.y; m_lx3+=m_potTracker.x; m_ly3+=m_potTracker.y; m_lx4+=m_potTracker.x; m_ly4+=m_potTracker.y; UPtoLP(m_lx1,m_ly1,&x1,&y1); UPtoLP(m_lx2,m_ly2,&x2,&y2); UPtoLP(m_lx3,m_ly3,&x3,&y3); UPtoLP(m_lx4,m_ly4,&x4,&y4); pDC->Arc(x1,y1,x2,y2,x3,y3,x4,y4); break; case TK_SP: m_lx3=m_potTracker.x; m_ly3=m_potTracker.y; UPtoLP(m_lx3,m_ly3,&x3,&y3); //pDC->Chord(x1,y1,x2,y2,x3,y3,x4,y4); pDC->Arc(x1,y1,x2,y2,x3,y3,x4,y4); break; case TK_EP: m_lx4=m_potTracker.x; m_ly4=m_potTracker.y; UPtoLP(m_lx4,m_ly4,&x4,&y4); //pDC->Chord(x1,y1,x2,y2,x3,y3,x4,y4); pDC->Arc(x1,y1,x2,y2,x3,y3,x4,y4); break; } pDC->SetROP2(R2_COPYPEN); pDC->SelectObject(pOldPen); pDC->SelectObject(pOldBrush); }
void CEllipse::DrawTracker(CDC *pDC) { LOGPEN tLogPen; tLogPen.lopnColor=RGB(0,0,0); tLogPen.lopnStyle=PS_DASH; tLogPen.lopnWidth.x=1; CPen tPen; tPen.CreatePenIndirect(&tLogPen); CPen *pOldPen=(CPen *)pDC->SelectObject(&tPen); CBrush *pOldBrush=(CBrush *)pDC->SelectStockObject(NULL_BRUSH); pDC->SetROP2(R2_NOTXORPEN); long x1,y1,x2,y2; UPtoLP(m_lx1,m_ly1,&x1,&y1); UPtoLP(m_lx2,m_ly2,&x2,&y2); pDC->Rectangle(x1,y1,x2,y2); switch(m_lHitTarget){ case TK_LT: m_lx1=m_potTracker.x; m_ly1=m_potTracker.y; UPtoLP(m_lx1,m_ly1,&x1,&y1); pDC->Rectangle(x1,y1,x2,y2); break; case TK_LB: m_lx1=m_potTracker.x; m_ly2=m_potTracker.y; UPtoLP(m_lx1,m_ly2,&x1,&y2); pDC->Rectangle(x1,y1,x2,y2); break; case TK_RT: m_lx2=m_potTracker.x; m_ly1=m_potTracker.y; UPtoLP(m_lx2,m_ly1,&x2,&y1); pDC->Rectangle(x1,y1,x2,y2); break; case TK_RB: m_lx2=m_potTracker.x; m_ly2=m_potTracker.y; UPtoLP(m_lx2,m_ly2,&x2,&y2); pDC->Rectangle(x1,y1,x2,y2); break; case TK_LM: m_lx1=m_potTracker.x; UPtoLP(m_lx1,m_ly1,&x1,&y1); pDC->Rectangle(x1,y1,x2,y2); break; case TK_TM: m_ly1=m_potTracker.y; UPtoLP(m_lx1,m_ly1,&x1,&y1); pDC->Rectangle(x1,y1,x2,y2); break; case TK_RM: m_lx2=m_potTracker.x; UPtoLP(m_lx2,m_ly2,&x2,&y2); pDC->Rectangle(x1,y1,x2,y2); break; case TK_BM: m_ly2=m_potTracker.y; UPtoLP(m_lx2,m_ly2,&x2,&y2); pDC->Rectangle(x1,y1,x2,y2); break; case TK_MOV: m_lx1+=m_potTracker.x; m_ly1+=m_potTracker.y; m_lx2+=m_potTracker.x; m_ly2+=m_potTracker.y; UPtoLP(m_lx1,m_ly1,&x1,&y1); UPtoLP(m_lx2,m_ly2,&x2,&y2); pDC->Rectangle(x1,y1,x2,y2); break; } pDC->SetROP2(R2_COPYPEN); pDC->SelectObject(pOldPen); pDC->SelectObject(pOldBrush); }
void CText::DrawTracker(CDC *pDC) { LOGPEN tLogPen; tLogPen.lopnColor=RGB(0,0,0); tLogPen.lopnStyle=PS_DOT; tLogPen.lopnWidth.x=1; CPen tPen; tPen.CreatePenIndirect(&tLogPen); CPen *pOldPen=(CPen *)pDC->SelectObject(&tPen); CBrush *pOldBrush=(CBrush *)pDC->SelectStockObject(NULL_BRUSH); LOGFONT tFont; tFont=m_font; UPtoLP(tFont.lfHeight,tFont.lfWidth,&tFont.lfHeight,&tFont.lfWidth); CFont font; font.CreateFontIndirect(&tFont); CFont *pOldFont=pDC->SelectObject(&font); pDC->SetROP2(R2_NOTXORPEN); long x1,y1,x2,y2; // UPtoLP(m_lx1,m_ly1,&x1,&y1); // UPtoLP(m_lx2,m_ly2,&x2,&y2); // long ly1,ly2; switch(m_lHitTarget) { case TK_CT: //pDC->SetTextColor(m_FaceColor); //pDC->TextOut(x1,y1,m_text); break; /* case TK_TM: ly1=m_potTracker.y; if((m_ly2-ly1)>=2*DELTA){ UPtoLP(m_lx1-DELTA,m_ly1-DELTA,&x1,&y1); UPtoLP(m_lx2+DELTA,m_ly2+DELTA,&x2,&y2); pDC->Rectangle(x1,y1,x2,y2); m_ly1=ly1+DELTA; m_font.lfHeight=m_ly2-m_ly1; UPtoLP(m_lx1-DELTA,m_ly1-DELTA,&x1,&y1); pDC->Rectangle(x1,y1,x2,y2); } break; case TK_BM: ly2=m_potTracker.y; if((ly2-m_ly1)>=2*DELTA){ UPtoLP(m_lx1-DELTA,m_ly1-DELTA,&x1,&y1); UPtoLP(m_lx2+DELTA,m_ly2+DELTA,&x2,&y2); pDC->Rectangle(x1,y1,x2,y2); m_ly2=ly2-DELTA; m_font.lfHeight=m_ly2-m_ly1; UPtoLP(m_lx2+DELTA,m_ly2+DELTA,&x2,&y2); pDC->Rectangle(x1,y1,x2,y2); } break; */ case TK_MOV: UPtoLP(Left()-DELTA,Top()-DELTA,&x1,&y1); UPtoLP(Right()+DELTA,Bottom()+DELTA,&x2,&y2); pDC->Rectangle(x1,y1,x2,y2); m_lx1+=m_potTracker.x; m_ly1+=m_potTracker.y; m_lx2+=m_potTracker.x; m_ly2+=m_potTracker.y; UPtoLP(Left()-DELTA,Top()-DELTA,&x1,&y1); UPtoLP(Right()+DELTA,Bottom()+DELTA,&x2,&y2); pDC->Rectangle(x1,y1,x2,y2); break; } //pDC->SetBkMode(OPAQUE); pDC->SetROP2(R2_COPYPEN); pDC->SelectObject(pOldFont); pDC->SelectObject(pOldPen); pDC->SelectObject(pOldBrush); }
void CDrawRect::Draw(CDC* pDC) { ASSERT_VALID(this); CBrush brush; if (!brush.CreateBrushIndirect(&m_logbrush)) return; CPen pen; if (!pen.CreatePenIndirect(&m_logpen)) return; CBrush* pOldBrush; CPen* pOldPen; if (m_bBrush) pOldBrush = pDC->SelectObject(&brush); else pOldBrush = (CBrush*)pDC->SelectStockObject(NULL_BRUSH); if (m_bPen) pOldPen = pDC->SelectObject(&pen); else pOldPen = (CPen*)pDC->SelectStockObject(NULL_PEN); CRect rect = m_position; switch (m_nShape) { case rectangle: pDC->Rectangle(rect); break; case roundRectangle: pDC->RoundRect(rect, m_roundness); break; case ellipse: pDC->Ellipse(rect); break; case line: if (rect.top > rect.bottom) { rect.top -= m_logpen.lopnWidth.y / 2; rect.bottom += (m_logpen.lopnWidth.y + 1) / 2; } else { rect.top += (m_logpen.lopnWidth.y + 1) / 2; rect.bottom -= m_logpen.lopnWidth.y / 2; } if (rect.left > rect.right) { rect.left -= m_logpen.lopnWidth.x / 2; rect.right += (m_logpen.lopnWidth.x + 1) / 2; } else { rect.left += (m_logpen.lopnWidth.x + 1) / 2; rect.right -= m_logpen.lopnWidth.x / 2; } pDC->MoveTo(rect.TopLeft()); pDC->LineTo(rect.BottomRight()); break; } pDC->SelectObject(pOldBrush); pDC->SelectObject(pOldPen); }