MFC画线,刚学,怎么发现改变不了笔的颜色 10
CFinal_elsView::CFinal_elsView(){//TODO:addconstructioncodeherethis->m_color=1;this->...
CFinal_elsView::CFinal_elsView()
{
// TODO: add construction code here
this->m_color=1;
this->m_difficulty=1;
}
void CFinal_elsView::OnDraw(CDC* pDC)
{
CFinal_elsDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
switch(this->m_color)
{
case 1: pDC->SelectObject(CPen(PS_SOLID,4,RGB(255,0,0))); break;
case 2: pDC->SelectObject(CPen(PS_SOLID,4,RGB(0,255,0))); break;
case 3: pDC->SelectObject(CPen(PS_SOLID,4,RGB(0,0,255))); break;
}
pDC->MoveTo(20,20);pDC->LineTo(220,20);
}
如上。。为何运行出来画的线是黑色。。不是应该是红色么。。。 展开
{
// TODO: add construction code here
this->m_color=1;
this->m_difficulty=1;
}
void CFinal_elsView::OnDraw(CDC* pDC)
{
CFinal_elsDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
switch(this->m_color)
{
case 1: pDC->SelectObject(CPen(PS_SOLID,4,RGB(255,0,0))); break;
case 2: pDC->SelectObject(CPen(PS_SOLID,4,RGB(0,255,0))); break;
case 3: pDC->SelectObject(CPen(PS_SOLID,4,RGB(0,0,255))); break;
}
pDC->MoveTo(20,20);pDC->LineTo(220,20);
}
如上。。为何运行出来画的线是黑色。。不是应该是红色么。。。 展开
展开全部
既然你选择的是画 画的东西当然要放在画的地方啊 在paint消息处理中编写程序吧
void CFinal_elsView::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
//dc.SelectObject
pen.CreatePen(PS_SOLID,20,RGB(255,0,0));
dc.SelectObject(pen);
dc.MoveTo(10,20);dc.LineTo(100,200);
// Do not call CView::OnPaint() for painting messages
}
pen是自定义的一个CPen 对象View类的公有成员 也可以定义在本函数中
void CFinal_elsView::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
//dc.SelectObject
pen.CreatePen(PS_SOLID,20,RGB(255,0,0));
dc.SelectObject(pen);
dc.MoveTo(10,20);dc.LineTo(100,200);
// Do not call CView::OnPaint() for painting messages
}
pen是自定义的一个CPen 对象View类的公有成员 也可以定义在本函数中
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询