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

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();

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

你可能感兴趣的:(schema,list,Class,pascal,attributes)