码迷,mamicode.com
首页 > 编程语言 > 详细

MFC宏

时间:2015-02-11 18:23:25      阅读:207      评论:0      收藏:0      [点我收藏+]

标签:

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
CRuntimeClass *m_pBaseClass;

CObject * CreateObject();
static CRuntimeClass * PASCAL Load();

//CRuntimeClass object linked together in simple list
static CRuntimeClass *pFirstClass; //start of class list
CRuntimeClass * m_pNextClass;
};
struct AFX_CLASSINIT
{
AFX_CLASSINIT(CRuntimeClass * pNewClass);
};

#define RUNTIME_CLASS(class_name) \
(&class_name::class##class_name)

#define DECLARE_DYNAMIC(class_name) \
public: \
static CRuntimeClass class##class_name; \
virtual CRuntimeClass * GetRuntimeClass() const;

#define DECLARE_DYNCREATE(class_name) \
DECLARE_DYNAMIC(class_name) \
static CObject * PASCAL CreateObject();

#define _IMPLEMENT_RUNTIMECLASS(class_name, base_class_name, wSchema, pfnNew) \
static char _lpsz##class_name[] = #class_name; \
CRuntimeClass class_name::class##class_name = { \
_lpsz##class_name, sizeof(class_name), wSchema, pfnNew, RUNTIME_CLASS(base_class_name), NULL }; \
static AFX_CLASSINIT _init_##class_name(&class_name::class##class_name);\
CRuntimeClass * class_name::GetRuntimeClass() const \
{ return &class_name::class##class_name; }

#define IMPLEMENT_DYNAMIC(class_name, base_class_name) \
_IMPLEMENT_RUNTIMECLASS(class_name, base_class_name, 0xFFFF, NULL)

#define IMPLEMENT_DYNCREATE(class_name ,base_class_name) \
CObject * PASCAL class_name::CreateObject() \
{return new class_name; } \
_IMPLEMENT_RUNTIMECLASS(class_name , base_class_name,0xFFFF, \
class_name::CreateObject)

MFC宏

标签:

原文地址:http://www.cnblogs.com/kobe-echo/p/4286445.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!