#define DECLARE_MESSAGE_MAP() \
protected: \
static const AFX_MSGMAP* GetThisMessageMap(); \
virtual const AFX_MSGMAP* GetMessageMap() const; \
#define BEGIN_MESSAGE_MAP(theClass, baseClass) \
const AFX_MSGMAP* theClass::GetMessageMap() const \
{ return GetThisMessageMap(); } \
const AFX_MSGMAP* theClass::GetThisMessageMap() \
{ \
typedef theClass ThisClass; \
typedef baseClass TheBaseClass; \
static const AFX_MSGMAP_ENTRY _messageEntries[] = \
{
#define END_MESSAGE_MAP() \
{0,(AFX_PMSG)0 } \
}; \
static const AFX_MSGMAP messageMap = \
{ &TheBaseClass::GetThisMessageMap, &_messageEntries[0] }; \
return &messageMap; \
}
#define ON_COMMAND(id, memberFxn) \
{ id, static_cast (memberFxn) },
这是C++的代码头文件中的一部分,希望大佬们帮我解释一下,不懂define啊
如果需要 我把剩余三个头文件粘贴在这里:
//Base.h
#pragma once
#include
#include "test.h"
using namespace std;
class CBase;
typedef void (CBase::*AFX_PMSG)(void);
struct AFX_MSGMAP_ENTRY
{
int nMessage; // windows message
AFX_PMSG pfn; // routine to call (or special value)
};
struct AFX_MSGMAP
{
const AFX_MSGMAP* (* pfnGetBaseMap)();
const AFX_MSGMAP_ENTRY* lpEntries;
};
class CBase
{
public:
CBase(void);
~CBase(void);
const AFX_MSGMAP_ENTRY* pMsgEntry;
AFX_PMSG pVIBaseMemFunc;
int messageid;
void GetMessage();
void DisPatchMessage();
virtual void initInstance();
DECLARE_MESSAGE_MAP()
};
//Current.h
#pragma once
#include "base.h"
class CCurrent :
public CBase
{
public:
CCurrent(void);
~CCurrent(void);
virtual void initInstance();
void coutid2();
void coutid4();
void coutid6();
void coutid8();
DECLARE_MESSAGE_MAP()
};
//Drived.h
#pragma once
#include "current.h"
class CDrived :
public CCurrent
{
public:
CDrived(void);
~CDrived(void);
virtual void initInstance();
void coutid1();
void coutid3();
void coutid5();
void coutid7();
DECLARE_MESSAGE_MAP()
};
定义了消息映射啊,头文件里没有注释怎么看得懂cpp里都实现了什么啊?
能调一调格式吗?这个就很迷了。