输入: void Lhuazhou::OnDraw(CDC* /*pDC*/) { pDC->MoveTo(200,200); pDC->LineTo(x,200);// TODO: 在此添加专用代码和/或调用基类 } 但是出错了:error C2065: 'pDC' : undeclared identifier error C2227: left of '->MoveTo' must point to class/struct/union/generic type error C2227: left of '->LineTo' must point to class/struct/union/generic type error C2065: 'lX1' : undeclared identifier 为什么
pDC->LineTo();目标点坐标
void Lhuazhou::OnDraw(CDC* /*pDC*/)
{
pDC->MoveTo(200,200);
pDC->LineTo(x,200);// TODO: 在此添加专用代码和/或调用基类
}
但是出错了:error C2065: 'pDC' : undeclared identifier
error C2227: left of '->MoveTo' must point to class/struct/union/generic type
error C2227: left of '->LineTo' must point to class/struct/union/generic type
error C2065: 'lX1' : undeclared identifier
为什么
1.直接按钮响应void Cxxxx::OnButton1()
{
CDC *pDC = this->GetDC;
pDC->MoveTO(CPoint OrgPoint);
pDC->LineTo(CPoint InputPoint);
ReleaseDC(pDC);
}
2.串行化吧,这样的话重画后也可以显示,是在OnDraw(CDC *pDC)里面写响应,不过就麻烦一点了^_^
如果是CView的CButton的话this ->GetDC()才是对的
但如果是对话框上的按钮,就利用参数记录下来,销毁对话框后发送自定义消息,自行处理。:P
然后在Lh类理添加了OnDraw()是这样写的
void Lh::OnDraw(CDC*pDC)
{
pDC->MoveTo(200,200);
pDC->LineTo(500,200);// TODO: 在此添加专用代码和/或调用基类
}
运行没什么错误,为什么在主面板里没什么显示
急求!!!!!!!!!!!!!!
=====================
当然出错了,上面pDC不是给你注释了吗?
然后在Lh类理添加了OnDraw()是这样写的
void Lh::OnDraw(CDC*pDC)
{
pDC->MoveTo(200,200);
pDC->LineTo(500,200);// TODO: 在此添加专用代码和/或调用基类
}
运行没什么错误,为什么在主面板里没什么显示 那可能是程序别的地方的问题,跟这两句没关系!