class CMsgFrame : public CFrameWnd
{
private:
static const AFX_MSGMAP_ENTRY _messageEntries[];
protected:
static AFX_DATA const AFX_MSGMAP messageMap;
static const AFX_MSGMAP* PASCAL _GetBaseMessageMap();
virtual const AFX_MSGMAP* GetMessageMap() const;
}
const AFX_MSGMAP* PASCAL CMsgFrame::_GetBaseMessageMap()
{
return &CFrameWnd::messageMap;
}
const AFX_MSGMAP* CMsgFrame::GetMessageMap() const
{
return &CMsgFrame::messageMap;
}
AFX_COMDAT AFX_DATADEF const AFX_MSGMAP CMsgFrame::messageMap =
{
&CMsgFrame::_GetBaseMessageMap,
&CMsgFrame::_messageEntries[0]
};
AFX_COMDAT const AFX_MSGMAP_ENTRY CMsgFrame::_messageEntries[] =
{
{ WM_PAINT, 0, 0, 0, AfxSig_lwl,(AFX_PMSG)(AFX_PMSGW)(LRESULT (AFX_MSG_CALL CWnd::*)(WPARAM, LPARAM))&OnPaint },
{0, 0, 0, 0, AfxSig_end, (AFX_PMSG)0 }
};
用宏包装了很多代码,实现消息映射。具体可以看深入浅出mfc。上面将的很清楚
即便注释这些代码,也不能完整说明消息映射宏是怎么工作的。
推荐你看《深入浅出MFC》的MFC7大特性模拟之消息映射模拟。
网上有这本书的电子版。