+ -
当前位置:首页 → 问答吧 → vs2008 DrawView.cpp(148) : error C2065: 'Cpen' : undeclared identifier

vs2008 DrawView.cpp(148) : error C2065: 'Cpen' : undeclared identifier

时间:2011-12-13

来源:互联网

void CDrawView::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default

//First in the method:

/* HDC hdc;
hdc=::GetDC(m_hWnd);
MoveToEx(hdc,m_ptOrigin.x,m_ptOrigin.y,NULL);
LineTo(hdc,point.x,point.y);
::ReleaseDC(m_hWnd,hdc);*/

//The second method:

/*CDC *pDC=GetDC();
pDC->MoveTo(m_ptOrigin);
pDC->LineTo (point);
ReleaseDC(pDC);*/

//The third in the method
/*CClientDC dc(this);
//CClientDC dc(GetParent());
dc.MoveTo (m_ptOrigin);
dc.LineTo (point);*/

//Fourth in the method
/* //CWindowDC dc(GetParent());
CWindowDC dc(GetDesktopWindow());
//CWindowDC dc(this);
dc.MoveTo (m_ptOrigin);
dc.LineTo (point);*/
//Fifth in the method

CPen pen(PS_SOLID,2,RGB(255,0,0));
CClientDC dc(this);
Cpen *pOldPen=dc.SelectObject (&pen);
   
dc.MoveTo (m_ptOrigin);
dc.LineTo (point);
  dc.SelectObject (pOldPen);
CView::OnLButtonUp(nFlags, point);

}
错误如下:
1>.\DrawView.cpp(148) : error C2065: 'Cpen' : undeclared identifier
1>.\DrawView.cpp(148) : error C2065: 'pOldPen' : undeclared identifier
1>.\DrawView.cpp(152) : error C2065: 'pOldPen' : undeclared identifier
希望高手指点,vs2008环境vc++

作者: b_w1988   发布时间: 2011-12-13

Cpen改为 CPen

作者: chinatcp   发布时间: 2011-12-13

Cpen *pOldPen=dc.SelectObject (&pen);

作者: dahaiI0   发布时间: 2011-12-13