undeclared identifier 怎么解决

F:\练习\EX04C\EX04CView.cpp(213) : error C2065: 'OnprepareDC' : undeclared identifier
F:\练习\EX04C\EX04CView.cpp(215) : error C2039: 'CPtoDP' : is not a member of 'CClientDC'
f:\vc++安装程序\mfc\include\afxwin.h(1035) : see declaration of 'CClientDC'
执行 cl.exe 时出错.
这些是我编写程序时出现的错误,请问大家怎样解决啊?
出错的地方如下:
void CEX04CView::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CClientDC dc(this);
OnprepareDC(&dc);
CRect rectDevice=m_rectEllipse;
dc.CPtoDP(rectDevice);
if(rectDevice.PtInRect(point))
{
if(m_nColor==GRAY_BRUSH)
{
m_nColor=WHITE_BRUSH;
}
else
{
m_nColor=GRAY_BRUSH;
}
InvalidateRect(m_rectEllipse);
}
// CScrollView::OnLButtonDown(nFlags, point);
}

class CClientDC : public CDC
{
DECLARE_DYNAMIC(CClientDC)

// Constructors
public:
CClientDC(CWnd* pWnd);

// Attributes
。。。。。。。。

第1个回答  2007-09-06
OnprepareDC(&dc);

函数变量没有定义。

这应该是某个自定义函数,你复制过来时候 没有复制这部分的定义和实现。

找到 它的定义,放到使用之前就行了。本回答被提问者采纳
相似回答