在MFC窗口重绘中(孙鑫视频11讲),书上是将graph设为指针变量,而我是将graph设为view类的数据成员
在MFC窗口重绘中(孙鑫视频11讲),书上是将graph设为指针变量,而我是将graph设为view类的数据成员,可是发生重绘时候,只显示最后一个图像,求高手解答!!![...
在MFC窗口重绘中(孙鑫视频11讲),书上是将graph设为指针变量,而我是将graph设为view类的数据成员,可是发生重绘时候,只显示最后一个图像,求高手解答!!!
[code=c]void CGraphic11View::OnLButtonUp(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default CClientDC dc(this); CBrush *pBrush=CBrush::FromHandle((HBRUSH)GetStockObject(NULL_BRUSH)); dc.SelectObject(pBrush); switch (m_nDrawType)
{ case 1: dc.SetPixel(point,RGB(255,0,0)); break; case 2: dc.MoveTo(m_OriginPoint); dc.LineTo(point); break; case 3: dc.Rectangle(CRect(m_OriginPoint,point)); break; case 4: dc.Ellipse(CRect(m_OriginPoint,point)); break; } graph.m_nDrawType=m_nDrawType; graph.m_ptOrigin=m_OriginPoint; graph.m_ptEnd=point; m_ptrArray.Add(&graph); CView::OnLButtonUp(nFlags, point);}[/code]
[code=c]void CGraphic11View::OnDraw(CDC* pDC){ CGraphic11Doc* pDoc = GetDocument(); ASSERT_VALID(pDoc); // TODO: add draw code for native data here for (int i=0;i<m_ptrArray.GetSize();i++) { switch (((CGraph*)(m_ptrArray.GetAt(i)))->m_nDrawType) { case 1: pDC->SetPixel(((CGraph*)m_ptrArray.GetAt(i))->m_ptEnd,RGB(255,0,0)); break; case 2: pDC->MoveTo(((CGraph*)m_ptrArray.GetAt(i))->m_ptOrigin); pDC->LineTo(((CGraph*)m_ptrArray.GetAt(i))->m_ptEnd); break; case 3: pDC->Rectangle(CRect(((CGraph*)m_ptrArray.GetAt(i))->m_ptOrigin, ((CGraph*)m_ptrArray.GetAt(i))->m_ptEnd)); break; case 4: pDC->Ellipse(CRect(((CGraph*)m_ptrArray.GetAt(i))->m_ptOrigin, ((CGraph*)m_ptrArray.GetAt(i))->m_ptEnd)); break; } }}[/code] 展开
[code=c]void CGraphic11View::OnLButtonUp(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default CClientDC dc(this); CBrush *pBrush=CBrush::FromHandle((HBRUSH)GetStockObject(NULL_BRUSH)); dc.SelectObject(pBrush); switch (m_nDrawType)
{ case 1: dc.SetPixel(point,RGB(255,0,0)); break; case 2: dc.MoveTo(m_OriginPoint); dc.LineTo(point); break; case 3: dc.Rectangle(CRect(m_OriginPoint,point)); break; case 4: dc.Ellipse(CRect(m_OriginPoint,point)); break; } graph.m_nDrawType=m_nDrawType; graph.m_ptOrigin=m_OriginPoint; graph.m_ptEnd=point; m_ptrArray.Add(&graph); CView::OnLButtonUp(nFlags, point);}[/code]
[code=c]void CGraphic11View::OnDraw(CDC* pDC){ CGraphic11Doc* pDoc = GetDocument(); ASSERT_VALID(pDoc); // TODO: add draw code for native data here for (int i=0;i<m_ptrArray.GetSize();i++) { switch (((CGraph*)(m_ptrArray.GetAt(i)))->m_nDrawType) { case 1: pDC->SetPixel(((CGraph*)m_ptrArray.GetAt(i))->m_ptEnd,RGB(255,0,0)); break; case 2: pDC->MoveTo(((CGraph*)m_ptrArray.GetAt(i))->m_ptOrigin); pDC->LineTo(((CGraph*)m_ptrArray.GetAt(i))->m_ptEnd); break; case 3: pDC->Rectangle(CRect(((CGraph*)m_ptrArray.GetAt(i))->m_ptOrigin, ((CGraph*)m_ptrArray.GetAt(i))->m_ptEnd)); break; case 4: pDC->Ellipse(CRect(((CGraph*)m_ptrArray.GetAt(i))->m_ptOrigin, ((CGraph*)m_ptrArray.GetAt(i))->m_ptEnd)); break; } }}[/code] 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询