CSDN博客

img zhoujiamurong

手写MFC----第一节DECLARE_DYNCREATE(mydoc)

发表于2004/7/11 21:39:00  5707人阅读

分类: MFC

DECLARE_DYNCREATE(mydoc)

定义为

#define DECLARE_DYNCREATE(class_name) /

         DECLARE_DYNAMIC(class_name) /

         static CObject* PASCAL CreateObject();

等同于

 DECLARE_DYNAMIC(mydoc) /

         static CObject* PASCAL CreateObject();

DECLARE_DYNAMIC又是什么呢?

定义为:

#define DECLARE_DYNAMIC(class_name) /

public: /

         static const AFX_DATA CRuntimeClass class##class_name; /

         virtual CRuntimeClass* GetRuntimeClass() const; /

 

那么

 

 

DECLARE_DYNAMIC(mydoc) /

         static CObject* PASCAL CreateObject();

等同于

public: /

         static const AFX_DATA CRuntimeClass class##mydoc; /

         virtual CRuntimeClass* GetRuntimeClass() const; /

static CObject* PASCAL CreateObject();

然后,再根据

#define PASCAL      __stdcall

#define AFX_CORE_DATA

#define AFX_DATA AFX_CORE_DATA

说明AFX_DATA啥也不是

##  为连接字符

等同于

public: /

         static const CRuntimeClass  classmydoc; /

         virtual CRuntimeClass* GetRuntimeClass() const; /

static CObject*  __stdcall  CreateObject();

然后,再根据

struct CRuntimeClass

{

// Attributes

         LPCSTR m_lpszClassName;

         int m_nObjectSize;

         UINT m_wSchema; // schema number of the loaded class

         CObject* (PASCAL* m_pfnCreateObject)(); // NULL => abstract class

#ifdef _AFXDLL

         CRuntimeClass* (PASCAL* m_pfnGetBaseClass)();

#else

         CRuntimeClass* m_pBaseClass;

#endif

 

// Operations

         CObject* CreateObject();

         BOOL IsDerivedFrom(const CRuntimeClass* pBaseClass) const;

 

// Implementation

         void Store(CArchive& ar) const;

         static CRuntimeClass* PASCAL Load(CArchive& ar, UINT* pwSchemaNum);

 

         // CRuntimeClass objects linked together in simple list

         CRuntimeClass* m_pNextClass;       // linked list of registered classes

};

说明CruntimeClass是个结构

DECLARE_DYNCREATE(mydoc)

就等同于

public: /

         static const CRuntimeClass  classmydoc; /

         virtual CRuntimeClass* GetRuntimeClass() const; /

static CObject*  __stdcall  CreateObject();

定义了三个内容,都是公有的成员,一个静态结构,两个函数。
0 0

相关博文

我的热门文章

img
取 消
img