如何在vc6中创建CObject的派生类
请问如何在vc6中派生Cobjec的类。刚才用MFC向导生成了一个多文档程序。然后工程中创建了Stroke.h和Stroke.cpp文件,以创建CStroke(继承CObject),可发现编译Stroke.cpp时一直错误。还望高手指点。
Stroke.h文件内容如下:
程序代码:
#ifndef CSTROKE_H #define CSTROKE_H #include "StdAfx.h" class CStroke:public CObject { public: CStroke(UINT nPenWidth); protected: CStroke(); DECLARE_SERIAL(CStroke) //成员变量 protected: UINT m_nPenWidth; public: CArray<CPoint,CPoint> m_pointArray; //操作 public: BOOL DrawStroke(CDC* pDC); virtual void Serialize(CArchive& ar); }; #endifStroke.cpp的内容:
程序代码:
#include "Stroke.h" IMPLENT_SERIAL(CStroke,CObject,1) CStroke::CStroke() { } CStroke::CStroke(UINT nPenWidth) { m_nPenWidth=nPenWidth; } 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=0;i<m_pointArray.GetSize();i++) { pDC->LineTo(m_pointArray[i]); } pDC->SelectObject(pOldPen); return TRUE; } void CStroke::Serialize(CArchive &ar) { if(ar.IsStoring) { ar<<(WORD)m_nPenWidth; } else { WORD v; ar>>v; m_nPenWidth=v; } m_pointArray.Serialize(ar); }编译时一直提示错误:unexpected end of file while looking for precompiled header directive
Error executing cl.exe.
郁闷啊!