BOOL CStroke::DrawStroke(CDC* pDC)
{
Cpen penStroke;
if(!penStroke.CreatePen(PS_SOLID,m_nPenWidth,RGB(0,0,0)))
return FALSE;
CPen* pOldPen=pDC->SelectObject(&penStroke);
pDC->MoveTo(m_pointArray[0]);
for (int i=1;i<m_pointArray.GetSize();i++)
{
pDC->LineTo(m_pointArray[i]);
}
pDC->SelectObject(pOldPen);
return TRUE;
}
void CDrawView::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
//Pressing the mouse button in the view window starts a new stroke
//CScrollView changes the viewport orign and mapping mode.
//It's necessary to convert the point from device coordinates
OnPrepareDC(&dc);//set up mapping mode and viewport orign
dc.DPtoLP(&point);
CPen* pOldPen=dc.SelectObject(pDC->GetCurrentPen());
dc.MoveTo(m_ptPrev);
dc.LineTo(point);
dc.SelectObject(pOldPen);
m_pStrokeCur->FinishStroke();
//Tell the other views that this stroke has been added
//so that they can invalidate this stroke's area in their
//client area.
pDoc->UpdateAllViews(this,0L,m_pStrokeCur);
ReleaseCapture();//Release the mouse capture established at
//the beginning of the mouse drag.
return;
}
void CDrawView::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default //Mouse button up is interesting in the draw application
//only if the user is currently drawing a new stroke by dragging
//the captured mouse.
if(GetCapture()!=this)
return;//If this window(view) didn't capture the mouse,
//then the user isn't drawing in this window.
CDrawDoc* pDoc=GetDocument();
CClientDC dc(this);
//CScrollView changes the viewport origin and mapping mode.
//It's necessary to convert the point from device coordinates
//to logical coordinates,such as are stored in the document.
return;//If this window(view) didn't capture the mouse,
//then the user isn't drawing in the window.
CClientDC dc(this);
//CScrollView changes the viewport origin and mapping mode .
//It's necesssary to convert the point from device coordinates
//to logical coordinates,such as are stored in the document.
OnPrepareDC(&dc);
dc.DPtoLP(&point);
m_pStrokeCur->m_pointArray.Add(point);
//Draw a line from the previous detected point in the mouse
//drag to the current point
CPen* pOldPen=dc.SelectObject(GetDocument()->GetCurrentPen());
dc.MoveTo(m_ptPrev);
dc.LineTo(point);
dc.SelectObject(pOldPen);
m_ptPrev=point;
return;
}void CDrawView::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
//Mouse movement is interesting in the Scribble application
//only if the user is currently drawing a new stroke by dragging
//the captured mouse.
if(GetCapture()!=this)
//to logical coordinates,such as are stored in the document.
CClientDC dc(this);
OnPrepareDC(&dc);
dc.DPtoLP(&point);
m_pStrokeCur=GetDocument()->NewStroke();
//Add first point to the new stroke
m_pStrokeCur->m_pointArray.Add(point);
SetCapture();//Capture the mouse until button up.
m_ptPrev=point;//Serves as the MoveTo() anchor point for the
//LoneTo() the next point,as the user drags the
//mouse.
return;
G:\Draw\DrawView.cpp(200) : error C2601: 'DrawStroke' : local function definitions are illegal
G:\Draw\DrawView.cpp(216) : error C2601: 'OnLButtonDown' : local function definitions are illegal
G:\Draw\DrawView.cpp(241) : error C2601: 'OnLButtonUp' : local function definitions are illegal
G:\Draw\DrawView.cpp(277) : error C2601: 'OnMouseMove' : local function definitions are illegal
G:\Draw\DrawView.cpp(298) : fatal error C1004: unexpected end of file found
请问各位高手这是怎么回事?
请问各位
{
Cpen penStroke;
if(!penStroke.CreatePen(PS_SOLID,m_nPenWidth,RGB(0,0,0)))
return FALSE;
CPen* pOldPen=pDC->SelectObject(&penStroke);
pDC->MoveTo(m_pointArray[0]);
for (int i=1;i<m_pointArray.GetSize();i++)
{
pDC->LineTo(m_pointArray[i]);
}
pDC->SelectObject(pOldPen);
return TRUE;
}
void CDrawView::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
//Pressing the mouse button in the view window starts a new stroke
//CScrollView changes the viewport orign and mapping mode.
//It's necessary to convert the point from device coordinates
OnPrepareDC(&dc);//set up mapping mode and viewport orign
dc.DPtoLP(&point);
CPen* pOldPen=dc.SelectObject(pDC->GetCurrentPen());
dc.MoveTo(m_ptPrev);
dc.LineTo(point);
dc.SelectObject(pOldPen);
m_pStrokeCur->FinishStroke();
//Tell the other views that this stroke has been added
//so that they can invalidate this stroke's area in their
//client area.
pDoc->UpdateAllViews(this,0L,m_pStrokeCur);
ReleaseCapture();//Release the mouse capture established at
//the beginning of the mouse drag.
return;
}
void CDrawView::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default //Mouse button up is interesting in the draw application
//only if the user is currently drawing a new stroke by dragging
//the captured mouse.
if(GetCapture()!=this)
return;//If this window(view) didn't capture the mouse,
//then the user isn't drawing in this window.
CDrawDoc* pDoc=GetDocument();
CClientDC dc(this);
//CScrollView changes the viewport origin and mapping mode.
//It's necessary to convert the point from device coordinates
//to logical coordinates,such as are stored in the document.
return;//If this window(view) didn't capture the mouse,
//then the user isn't drawing in the window.
CClientDC dc(this);
//CScrollView changes the viewport origin and mapping mode .
//It's necesssary to convert the point from device coordinates
//to logical coordinates,such as are stored in the document.
OnPrepareDC(&dc);
dc.DPtoLP(&point);
m_pStrokeCur->m_pointArray.Add(point);
//Draw a line from the previous detected point in the mouse
//drag to the current point
CPen* pOldPen=dc.SelectObject(GetDocument()->GetCurrentPen());
dc.MoveTo(m_ptPrev);
dc.LineTo(point);
dc.SelectObject(pOldPen);
m_ptPrev=point;
return;
}void CDrawView::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
//Mouse movement is interesting in the Scribble application
//only if the user is currently drawing a new stroke by dragging
//the captured mouse.
if(GetCapture()!=this)
//to logical coordinates,such as are stored in the document.
CClientDC dc(this);
OnPrepareDC(&dc);
dc.DPtoLP(&point);
m_pStrokeCur=GetDocument()->NewStroke();
//Add first point to the new stroke
m_pStrokeCur->m_pointArray.Add(point);
SetCapture();//Capture the mouse until button up.
m_ptPrev=point;//Serves as the MoveTo() anchor point for the
//LoneTo() the next point,as the user drags the
//mouse.
return;
G:\Draw\DrawView.cpp(200) : error C2601: 'DrawStroke' : local function definitions are illegal
G:\Draw\DrawView.cpp(216) : error C2601: 'OnLButtonDown' : local function definitions are illegal
G:\Draw\DrawView.cpp(241) : error C2601: 'OnLButtonUp' : local function definitions are illegal
G:\Draw\DrawView.cpp(277) : error C2601: 'OnMouseMove' : local function definitions are illegal
G:\Draw\DrawView.cpp(298) : fatal error C1004: unexpected end of file found
请问各位高手这是怎么回事?
请问各位
解决方案 »
- 关于16位BMP图片提取像素点的问题
- int *m_nPortStat;//端口状态 全局变量,预实现*(m_nPortStat+i)= new int(1);i为变量,怎么做?
- 【新手求组】怎么样写一个Windows服务程序,请大家赐教
- 请教高手~~~
- 把dos下运行的c++程序放入MFC的对话框中运行?
- 把图片指定颜色给透明,以显示背景图,请指教。
- 问个简单的问题:如何改变CFileDialog对话框的标题?用SetWindowText会出错啊
- 有关ActiveX的属性页问题
- 请问如何实现一个对话框程序可以用鼠标拖动改变其大小:)
- 如何得知鼠标单击在listctrl的那一行上?并把该行的数据取出来?
- 大家来讨论一下Exe运行时删除自己,关键是在运行时而不是等结束了...
- 哪里有《Visual C++6.0数据库开发技巧与实例》可以下载?
在projects->Setting->C/C++ ->Precompiled Header
然后在"files"中选中这个cpp文件
最后选择Not Using precompiled headers试试也许有用!
还可以把光标定位在一个花括号的里面,按ctrl+],光标就会自动跳转到这个花括号对应的另一个括号那里去。或者安装一个VisualAssist6,把光标定位在花括号内部,两个括号就会自动变色了。
三种方法,我不信楼主还找不出究竟少了哪个括号,呵呵
DrawView.obj : error LNK2001: unresolved external symbol "public: static struct CRuntimeClass CStroke::classCStroke" (?classCStroke@CStroke@@2UCRuntimeClass@@A)
Debug/Draw.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.感谢楼上的各位,问题已经解决,可是编译后又出现如下错误,哈!!
不明白啊!!!
Debug/Draw.exe : fatal error LNK1120: 1 unresolved externalswhy