64,282
社区成员
发帖
与我相关
我的任务
分享
void CMyView::OnDraw(CDC* pDC)
{
CMyDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
extern BOOL Whether_repaint;
CBrush *pBrush=CBrush::FromHandle((HBRUSH)GetStockObject(NULL_BRUSH));
pDC->SelectObject(pBrush);
if(Whether_repaint==TRUE)
{
for(int i=0;i<m_ptrArray1.GetSize();i++)//几何图形的重绘
{
CPen pen(((CGraph*)m_ptrArray1.GetAt(i))->CG_nLineStyle,((CGraph*)m_ptrArray1.GetAt(i))->CG_number4,
RGB(((CGraph*)m_ptrArray1.GetAt(i))->CG_number1,((CGraph*)m_ptrArray1.GetAt(i))->CG_number2,
((CGraph*)m_ptrArray1.GetAt(i))->CG_number3));
CPen *pOldPen=pDC->SelectObject(&pen);
switch(((CGraph*)m_ptrArray1.GetAt(i))->CG_nDrawType)
{
case 1:
pDC->MoveTo(((CGraph*)m_ptrArray1.GetAt(i))->CG_ptOrigin);
pDC->LineTo(((CGraph*)m_ptrArray1.GetAt(i))->CG_ptOrigin);
break;
case 2:
pDC->MoveTo(((CGraph*)m_ptrArray1.GetAt(i))->CG_ptOrigin);
pDC->LineTo(((CGraph*)m_ptrArray1.GetAt(i))->CG_ptEnd);
break;
case 3:
pDC->Rectangle(CRect(((CGraph*)m_ptrArray1.GetAt(i))->CG_ptOrigin,((CGraph*)m_ptrArray1.GetAt(i))->CG_ptEnd));
break;
case 4:
pDC->Ellipse(CRect(((CGraph*)m_ptrArray1.GetAt(i))->CG_ptOrigin,((CGraph*)m_ptrArray1.GetAt(i))->CG_ptEnd));
break;
}
}
for(int j=0;j<m_ptrArray2.GetSize()-1;j++)//连续线条的重绘
{
CPen pen(((CGraph*)m_ptrArray2.GetAt(j))->CG_nLineStyle,((CGraph*)m_ptrArray2.GetAt(j))->CG_number4,
RGB(((CGraph*)m_ptrArray2.GetAt(j))->CG_number1,((CGraph*)m_ptrArray2.GetAt(j))->CG_number2,
((CGraph*)m_ptrArray2.GetAt(j))->CG_number3));
CPen *pOldPen=pDC->SelectObject(&pen);
pDC->MoveTo(((CGraph*)m_ptrArray2.GetAt(j))->CG_ptOrigin);
pDC->LineTo(((CGraph*)m_ptrArray2.GetAt(j+1))->CG_ptOrigin);
}
}
Whether_repaint=TRUE;
// TODO: add draw code for native data here
}void CMyView::OnDraw(CDC* pDC)
{
CMyDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
extern BOOL Whether_repaint;
CBrush *pBrush=CBrush::FromHandle((HBRUSH)GetStockObject(NULL_BRUSH));
pDC->SelectObject(pBrush);
if(Whether_repaint==TRUE)
{
for(int i=0;i<m_ptrArray1.GetSize();i++)//几何图形的重绘
{
CPen pen(((CGraph*)m_ptrArray1.GetAt(i))->CG_nLineStyle,((CGraph*)m_ptrArray1.GetAt(i))->CG_number4,
RGB(((CGraph*)m_ptrArray1.GetAt(i))->CG_number1,((CGraph*)m_ptrArray1.GetAt(i))->CG_number2,
((CGraph*)m_ptrArray1.GetAt(i))->CG_number3));
CPen *pOldPen=pDC->SelectObject(&pen);
switch(((CGraph*)m_ptrArray1.GetAt(i))->CG_nDrawType)
{
case 1:
pDC->MoveTo(((CGraph*)m_ptrArray1.GetAt(i))->CG_ptOrigin);
pDC->LineTo(((CGraph*)m_ptrArray1.GetAt(i))->CG_ptOrigin);
break;
case 2:
pDC->MoveTo(((CGraph*)m_ptrArray1.GetAt(i))->CG_ptOrigin);
pDC->LineTo(((CGraph*)m_ptrArray1.GetAt(i))->CG_ptEnd);
break;
case 3:
pDC->Rectangle(CRect(((CGraph*)m_ptrArray1.GetAt(i))->CG_ptOrigin,((CGraph*)m_ptrArray1.GetAt(i))->CG_ptEnd));
break;
case 4:
pDC->Ellipse(CRect(((CGraph*)m_ptrArray1.GetAt(i))->CG_ptOrigin,((CGraph*)m_ptrArray1.GetAt(i))->CG_ptEnd));
break;
}
}
for(int j=0;j<m_ptrArray2.GetSize()-1;j++)//连续线条的重绘
{
CPen pen(((CGraph*)m_ptrArray2.GetAt(j))->CG_nLineStyle,((CGraph*)m_ptrArray2.GetAt(j))->CG_number4,
RGB(((CGraph*)m_ptrArray2.GetAt(j))->CG_number1,((CGraph*)m_ptrArray2.GetAt(j))->CG_number2,
((CGraph*)m_ptrArray2.GetAt(j))->CG_number3));
CPen *pOldPen=pDC->SelectObject(&pen);
pDC->MoveTo(((CGraph*)m_ptrArray2.GetAt(j))->CG_ptOrigin);
pDC->LineTo(((CGraph*)m_ptrArray2.GetAt(j+1))->CG_ptOrigin);
}
}
Whether_repaint=TRUE;
// TODO: add draw code for native data here
}
这个是刷白的响应函数:
void CMyView::OnRepaint()
{
extern BOOL Whether_repaint;
Whether_repaint=FALSE;
CMyView::OnPaint();
}
void CMyView::OnDraw(CDC* pDC)
{
CMyDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
extern BOOL Whether_repaint;
CBrush *pBrush=CBrush::FromHandle((HBRUSH)GetStockObject(NULL_BRUSH));
pDC->SelectObject(pBrush);
if(Whether_repaint==TRUE)
{
for(int i=0;i<m_ptrArray1.GetSize();i++)//几何图形的重绘
{
CPen pen(((CGraph*)m_ptrArray1.GetAt(i))->CG_nLineStyle,((CGraph*)m_ptrArray1.GetAt(i))->CG_number4,
RGB(((CGraph*)m_ptrArray1.GetAt(i))->CG_number1,((CGraph*)m_ptrArray1.GetAt(i))->CG_number2,
((CGraph*)m_ptrArray1.GetAt(i))->CG_number3));
CPen *pOldPen=pDC->SelectObject(&pen);
switch(((CGraph*)m_ptrArray1.GetAt(i))->CG_nDrawType)
{
case 1:
pDC->MoveTo(((CGraph*)m_ptrArray1.GetAt(i))->CG_ptOrigin);
pDC->LineTo(((CGraph*)m_ptrArray1.GetAt(i))->CG_ptOrigin);
break;
case 2:
pDC->MoveTo(((CGraph*)m_ptrArray1.GetAt(i))->CG_ptOrigin);
pDC->LineTo(((CGraph*)m_ptrArray1.GetAt(i))->CG_ptEnd);
break;
case 3:
pDC->Rectangle(CRect(((CGraph*)m_ptrArray1.GetAt(i))->CG_ptOrigin,((CGraph*)m_ptrArray1.GetAt(i))->CG_ptEnd));
break;
case 4:
pDC->Ellipse(CRect(((CGraph*)m_ptrArray1.GetAt(i))->CG_ptOrigin,((CGraph*)m_ptrArray1.GetAt(i))->CG_ptEnd));
break;
}
}
for(int j=0;j<m_ptrArray2.GetSize()-1;j++)//连续线条的重绘
{
CPen pen(((CGraph*)m_ptrArray2.GetAt(j))->CG_nLineStyle,((CGraph*)m_ptrArray2.GetAt(j))->CG_number4,
RGB(((CGraph*)m_ptrArray2.GetAt(j))->CG_number1,((CGraph*)m_ptrArray2.GetAt(j))->CG_number2,
((CGraph*)m_ptrArray2.GetAt(j))->CG_number3));
CPen *pOldPen=pDC->SelectObject(&pen);
pDC->MoveTo(((CGraph*)m_ptrArray2.GetAt(j))->CG_ptOrigin);
pDC->LineTo(((CGraph*)m_ptrArray2.GetAt(j+1))->CG_ptOrigin);
}
}
//Whether_repaint=TRUE;把这句删掉
// TODO: add draw code for native data here
}
void CMyView::OnRepaint()
{
Whether_repaint=!Whether_repaint;
}