一、关于DECLARE_MESSAGE_MAP宏定义
使用MFC向导,在ApplicationType页面选择DialogBased,生成一个对话框项目,Dialog类命名为CCapturePacketDlg,在CCapturePacketDlg.cpp中自动产生下列代码:
![](http://writeblog.csdn.net/Images/OutliningIndicators/None.gif)
2
![](http://writeblog.csdn.net/Images/OutliningIndicators/None.gif)
3
![](http://writeblog.csdn.net/Images/OutliningIndicators/None.gif)
- 先来分析ON_WM_PAINT(),在头文件“afxmsg.h”有它的宏定义,如下:
![](http://writeblog.csdn.net/Images/OutliningIndicators/None.gif)
2
![](http://writeblog.csdn.net/Images/OutliningIndicators/ExpandedBlockStart.gif)
3
![](http://writeblog.csdn.net/Images/OutliningIndicators/InBlock.gif)
4
![](http://writeblog.csdn.net/Images/OutliningIndicators/ExpandedBlockEnd.gif)
2.1 #define WM_PAINT 0x000F
2.2 AfxSig_vv = AfxSig_v_v_v
2.2.1 enum AfxSig::AfxSig_v_v_v = 19
3.1 AFX_PMSG:typedef void (AFX_MSG_CALL CCmdTarget::*AFX_PMSG)(void); //为一个函数指针
3.2 AFX_PMSGW:typedef void (AFX_MSG_CALL CWnd::*AFX_PMSGW)(void); //为一个函数指针
将ON_WM_PAINT()完全展开:
![](http://writeblog.csdn.net/Images/OutliningIndicators/ExpandedBlockStart.gif)
2
![](http://writeblog.csdn.net/Images/OutliningIndicators/InBlock.gif)
3
![](http://writeblog.csdn.net/Images/OutliningIndicators/InBlock.gif)
4
![](http://writeblog.csdn.net/Images/OutliningIndicators/InBlock.gif)
5
![](http://writeblog.csdn.net/Images/OutliningIndicators/InBlock.gif)
6
![](http://writeblog.csdn.net/Images/OutliningIndicators/InBlock.gif)
7
![](http://writeblog.csdn.net/Images/OutliningIndicators/InBlock.gif)
8
![](http://writeblog.csdn.net/Images/OutliningIndicators/InBlock.gif)
9
![](http://writeblog.csdn.net/Images/OutliningIndicators/ExpandedBlockEnd.gif)
2. 再来分析BEGIN_MESSAGE_MAP(CCapturePacketDlg, CDialog),在“afxwin.h”中有定义:
![](http://writeblog.csdn.net/Images/OutliningIndicators/None.gif)
2
![](http://writeblog.csdn.net/Images/OutliningIndicators/None.gif)
3
![](http://writeblog.csdn.net/Images/OutliningIndicators/None.gif)
4
![](http://writeblog.csdn.net/Images/OutliningIndicators/ExpandedBlockStart.gif)
5
![](http://writeblog.csdn.net/Images/OutliningIndicators/None.gif)
6
![](http://writeblog.csdn.net/Images/OutliningIndicators/ExpandedBlockStart.gif)
7
![](http://writeblog.csdn.net/Images/OutliningIndicators/InBlock.gif)
8
![](http://writeblog.csdn.net/Images/OutliningIndicators/InBlock.gif)
9
![](http://writeblog.csdn.net/Images/OutliningIndicators/InBlock.gif)
10
![](http://writeblog.csdn.net/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
2.1 PTM_WARNING_DISABLE:
#define PTM_WARNING_DISABLE /
__pragma(warning( push )) / //#pragma warning( push [ ,n ] ),Where n represents a warning level (1 through 4).
//The pragma warning( push ) stores the current warning state for all warnings.
__pragma(warning( disable : 4867 ))//Do not issue the specified warning message(s).
//http://msdn2.microsoft.com/en-us/2c8f766e.aspx
// Allows selective modification of the behavior of compiler warning messages.
3.1 struct AFX_MSGMAP
{
3.1.1 const AFX_MSGMAP* (PASCAL* pfnGetBaseMap)();
3.1.2 const AFX_MSGMAP_ENTRY* lpEntries;
};
3.1.2 struct AFX_MSGMAP_ENTRY
{
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_PTR nSig; // signature type (action) or pointer to message #
3.1.2.1 AFX_PMSG pfn; // routine to call (or special value)
};
3.1.2.1 typedef void (AFX_MSG_CALL CCmdTarget::*AFX_PMSG)(void);
5.1 #define PASCAL __stdcall
将BEGIN_MESSAGE_MAP(CCapturePacketDlg, CDialog)完全展开:
![](http://writeblog.csdn.net/Images/OutliningIndicators/None.gif)
2
![](http://writeblog.csdn.net/Images/OutliningIndicators/None.gif)
3
![](http://writeblog.csdn.net/Images/OutliningIndicators/ExpandedBlockStart.gif)
4
![](http://writeblog.csdn.net/Images/OutliningIndicators/InBlock.gif)
5
![](http://writeblog.csdn.net/Images/OutliningIndicators/ExpandedBlockEnd.gif)
6
![](http://writeblog.csdn.net/Images/OutliningIndicators/None.gif)
7
![](http://writeblog.csdn.net/Images/OutliningIndicators/ExpandedBlockStart.gif)
8
![](http://writeblog.csdn.net/Images/OutliningIndicators/InBlock.gif)
9
![](http://writeblog.csdn.net/Images/OutliningIndicators/InBlock.gif)
10
![](http://writeblog.csdn.net/Images/OutliningIndicators/InBlock.gif)
11
![](http://writeblog.csdn.net/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
3 最后分析END_MESSAGE_MAP(),在“afxwin.h”中有定义:
![](http://writeblog.csdn.net/Images/OutliningIndicators/None.gif)
2
![](http://writeblog.csdn.net/Images/OutliningIndicators/ExpandedBlockStart.gif)
3
![](http://writeblog.csdn.net/Images/OutliningIndicators/None.gif)
4
![](http://writeblog.csdn.net/Images/OutliningIndicators/None.gif)
5
![](http://writeblog.csdn.net/Images/OutliningIndicators/ExpandedBlockStart.gif)
6
![](http://writeblog.csdn.net/Images/OutliningIndicators/None.gif)
7
![](http://writeblog.csdn.net/Images/OutliningIndicators/None.gif)
8
![](http://writeblog.csdn.net/Images/OutliningIndicators/None.gif)
2.1 AfxSig_end:enum AfxSig.AfxSig_end = 0
2.2 AFX_PMSG:typedef void (AFX_MSG_CALL CCmdTarget::*AFX_PMSG)(void);//函数指针
4.1 struct AFX_MSGMAP
{
const AFX_MSGMAP* (PASCAL* pfnGetBaseMap)();
const AFX_MSGMAP_ENTRY* lpEntries;
};
8.1 #define PTM_WARNING_RESTORE /
__pragma(warning( pop ))
//pop restores the state of all warnings (including 4705, 4706, and 4707) to what it was at the beginning of the code.
·最后将
![](http://writeblog.csdn.net/Images/OutliningIndicators/None.gif)
2
![](http://writeblog.csdn.net/Images/OutliningIndicators/None.gif)
3
![](http://writeblog.csdn.net/Images/OutliningIndicators/None.gif)
![](http://writeblog.csdn.net/Images/OutliningIndicators/None.gif)
2
![](http://writeblog.csdn.net/Images/OutliningIndicators/None.gif)
3
![](http://writeblog.csdn.net/Images/OutliningIndicators/ExpandedBlockStart.gif)
4
![](http://writeblog.csdn.net/Images/OutliningIndicators/InBlock.gif)
5
![](http://writeblog.csdn.net/Images/OutliningIndicators/ExpandedBlockEnd.gif)
6
![](http://writeblog.csdn.net/Images/OutliningIndicators/None.gif)
7
![](http://writeblog.csdn.net/Images/OutliningIndicators/ExpandedBlockStart.gif)
8
![](http://writeblog.csdn.net/Images/OutliningIndicators/InBlock.gif)
9
![](http://writeblog.csdn.net/Images/OutliningIndicators/InBlock.gif)
10
![](http://writeblog.csdn.net/Images/OutliningIndicators/InBlock.gif)
11
![](http://writeblog.csdn.net/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
12
![](http://writeblog.csdn.net/Images/OutliningIndicators/ExpandedSubBlockStart.gif)