typedef void (CCmdTarget::*AFX_PMSG)(void);

struct AFX_MSGMAP_ENTRY  // MFC 4.0
{
    UINT nMessage;    
// windows message
    UINT nCode;            // control code or WM_NOTIFY code
    UINT nID;                // control ID (or 0 for windows messages)
    UINT nLastID;        // used for entries specifying a range of control id's
    UINT nSig;            // signature type (action) or pointer to message #
    AFX_PMSG pfn;    // routine to call (or special value)
}
;

struct AFX_MSGMAP
{
        AFX_MSGMAP
* pBaseMessageMap;
        AFX_MSGMAP_ENTRY
* lpEntries;
}
;

#define DECLARE_MESSAGE_MAP() \
        
static AFX_MSGMAP_ENTRY _messageEntries[]; \
        
static AFX_MSGMAP messageMap; \
        
virtual AFX_MSGMAP* GetMessageMap() const;

#define BEGIN_MESSAGE_MAP(theClass, baseClass) \
        AFX_MSGMAP
* theClass::GetMessageMap() const \
                
return &theClass::messageMap; } \
        AFX_MSGMAP theClass::messageMap 
= \
        
&(baseClass::messageMap), \
                (AFX_MSGMAP_ENTRY
*&(theClass::_messageEntries) }
; \
        AFX_MSGMAP_ENTRY theClass::_messageEntries[] 
= \
        
{

#define ON_COMMAND(id, memberFxn) \
        
{ WM_COMMAND, CN_COMMAND, (WORD)id, (WORD)id, AfxSig_vv, (AFX_PMSG)memberFxn },

#define END_MESSAGE_MAP() \
        
0000, AfxSig_end, (AFX_PMSG)0 } \
        }
;

enum AfxSig
{
        AfxSig_end 
= 0,     // [marks end of message map]
        AfxSig_vv,
}
;
posted on 2008-03-20 23:02  BlueTzar  阅读(499)  评论(0)    收藏  举报