(!a) return; if(type==1) { pdc->MoveTo(p1.x,p1.y); pdc->LineTo(p2.x,p2.y); p2=point; pdc->MoveTo(p1.x,p1.y); pdc->LineTo(p2.x,p2.y); } else if(type==2) { pdc->Ellipse(p1.x,p1.y,p2.x,p2.y); p2=point; pdc->Ellipse(p1.x,p1.y,p2.x,p2.y); } else if(type==3) { pdc->Rectangle(p1.x,p1.y,p2.x,p2.y); p2=point; pdc->Rectangle(p1.x,p1.y,p2.x,p2.y); } else if(type==4) { p2=point; pdc->MoveTo(p1.x,p1.y); pdc->LineTo(p2.x,p2.y); p1=point; } CView::OnMouseMove(nFlags, point); } void ChuituView::OnLButtonUp(UINT nFlags, CPoint point) {//释放鼠标左键 pdc->SetROP2(R2_COPYPEN); if(type==1) { pdc->MoveTo(p1.x,p1.y); pdc->LineTo(point.x,point.y); } else if(type==2) { pdc->Ellipse(p1.x,p1.y,point.x,point.y); } else if(type==3) { pdc->Rectangle(p1.x,p1.y,point.x,point.y);
} else if(type==4) { pdc->MoveTo(p1.x,p1.y); pdc->LineTo(point.x,point.y); } a=false; CView::OnLButtonUp(nFlags, point); } void ChuituView::Onxzlolor() { // 线条颜色选择 CColorDialog dlg(0,CC_FULLOPEN); if(dlg.DoModal()) { color=dlg.GetColor(); } } void ChuituView::Ontccolor() { // 填充颜色 CColorDialog dlg(0,CC_FULLOPEN); if(dlg.DoModal()) { tccolor=dlg.GetColor(); tc=true; } } void ChuituView::Onwtc() { // 无类型,直接用颜色填充 tcstyle=5; tc=true; } void ChuituView::Onx() { width=1; } void ChuituView::Onc() { width=2; } void ChuituView::Onsx() { style=0; } void ChuituView::Onxx() { style=1; }