MFC中,有好多注解宏,我现在用点晕了,不知道哪个是宏,哪个是注解,那些是有用的,有什么地方用,哪里是没用的,彻彻底底的就是注解....
比如说下面的.BEGIN_MESSAGE_MAP(CTang20110503View, CFormView)
//{{AFX_MSG_MAP(CTang20110503View)
ON_WM_CREATE()
ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CFormView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CFormView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CFormView::OnFilePrintPreview)
END_MESSAGE_MAP()
比如说上面的消息映射....
//{{AFX_MSG_MAP(CTang20110503View) --------这个有无用
还有,我自己用手敲进去的函数应该写在什么地方?

解决方案 »

  1.   

    我自己写进去的 放在 
       //{{AFX_MSG_MAP(CTang20110503View)
    ......放在这里面还是这外面
        //}}AFX_MSG_MAP
        // Standard printing commands
      

  2.   

    #define BEGIN_MESSAGE_MAP(theClass, baseClass) \
    PTM_WARNING_DISABLE \
    const AFX_MSGMAP* theClass::GetMessageMap() const \
    { return GetThisMessageMap(); } \
    const AFX_MSGMAP* PASCAL theClass::GetThisMessageMap() \
    { \
    typedef theClass ThisClass;    \
    typedef baseClass TheBaseClass;    \
    static const AFX_MSGMAP_ENTRY _messageEntries[] =  \
    {#define END_MESSAGE_MAP() \
    {0, 0, 0, 0, AfxSig_end, (AFX_PMSG)0 } \
    }; \
      

  3.   

    实际上就是实现了两个函数 GetMessageMap  GetThisMessageMap
    返回一个 AFX_MSGMAP_ENTRY 结构体的数组
    下面的都是往这个结构体中加东西(都可以看到定义)
        ON_WM_CREATE()
        ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
        //}}AFX_MSG_MAP
        // Standard printing commands
        ON_COMMAND(ID_FILE_PRINT, CFormView::OnFilePrint)
        ON_COMMAND(ID_FILE_PRINT_DIRECT, CFormView::OnFilePrint)
        ON_COMMAND(ID_FILE_PRINT_PREVIEW, CFormView::OnFilePrintPreview)
    某个地方会掉GetMessageMap获取这个数组,
    依据收到的消息在这个数组里面找对应的响应函数并调用这些都是消息相关的。。自己加的函数 就像加普通的c++函数一样 
      

  4.   

    这个我也不好说  可以说是续行符 代表下一行是跟本行是一起的比如
    #define a  f
    ffa
    此时a为f如果
    #define a  f \
    ffa测试a为 f ffa因为#define只能一行 如果#define太长,写起来不美观,也不好读代码 所以 用“\”来续航#define BEGIN_MESSAGE_MAP(theClass, baseClass) \
    PTM_WARNING_DISABLE \
    const AFX_MSGMAP* theClass::GetMessageMap() const \
    { return GetThisMessageMap(); } \
    const AFX_MSGMAP* PASCAL theClass::GetThisMessageMap() \
    { \
    typedef theClass ThisClass;  \
    typedef baseClass TheBaseClass;  \
    static const AFX_MSGMAP_ENTRY _messageEntries[] = \
    {#define END_MESSAGE_MAP() \
    {0, 0, 0, 0, AfxSig_end, (AFX_PMSG)0 } \
    }; \
    等价于#define BEGIN_MESSAGE_MAP(theClass, baseClass) PTM_WARNING_DISABLE const AFX_MSGMAP* theClass::GetMessageMap() const  { return GetThisMessageMap(); } const AFX_MSGMAP* PASCAL theClass::GetThisMessageMap()  {  typedef theClass ThisClass;  typedef baseClass TheBaseClass;   static const AFX_MSGMAP_ENTRY _messageEntries[] =  {#define END_MESSAGE_MAP() {0, 0, 0, 0, AfxSig_end, (AFX_PMSG)0 }  };