zoukankan      html  css  js  c++  java
  • DECLARE_MESSAGE_MAP 宏

      此宏描述的头文件位置: afxwin.h

    如果在 DECLARE_MESSAGE_MAP之后声明任何成员,则必须为其指定新的访问类型 (公共、 private或 protected)。说明:定义消息映射的声明类。 你的应用程序的每个 CCmdTarget 派生类,必须提供消息映射来处理消息。

    有关消息映射和 DECLARE_MESSAGE_MAP 宏的更多信息,请参见 消息处理和映射主题

    在类声明的末尾处使用 DECLARE_MESSAGE_MAP 宏。

    class CHelloApp:public CWinApp

    {

     // ……

     DECLARE_MESSAGE_MAP()

    };

    然后在定义这个类的成员函数的的 .cpp 文件中,使用 BEGIN_MESSAGE_MAP 宏、每一个消息处理函数的宏入口和 END_MESSAGE_MAP 宏。

     BEGIN_MESSAGE_MAP(CHelloMFCApp, CWinApp)
     //{{AFX_MSG_MAP(CHelloMFCApp)
     ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
      // NOTE - the ClassWizard will add and remove mapping macros here.
      //    DO NOT EDIT what you see in these blocks of generated code!
     //}}AFX_MSG_MAP
     // Standard file based document commands
     ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
     ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
    END_MESSAGE_MAP()


    如果在 DECLARE_MESSAGE_MAP之后声明任何成员,则必须为其指定新的访问类型 (公共、 private或 protected)。
    下面是错误的代码:(其实我也不知道为什么,官方文档给的说明,我试过删掉 private 也可以

    class CHelloMFCApp : public CWinApp
    {
    public:
     CHelloMFCApp();

    // Overrides
     // ClassWizard generated virtual function overrides
     //{{AFX_VIRTUAL(CHelloMFCApp)
     public:
     virtual BOOL InitInstance();
     //}}AFX_VIRTUAL

    // Implementation
     //{{AFX_MSG(CHelloMFCApp)
     afx_msg void OnAppAbout();
      // NOTE - the ClassWizard will add and remove member functions here.
      //    DO NOT EDIT what you see in these blocks of generated code !
     //}}AFX_MSG
     DECLARE_MESSAGE_MAP()

    private:  // 此处不能丢

    int i;
    };

     
  • 相关阅读:
    route-over VS mesh-under
    IOS算法(三)之插入排序
    GitHub学习笔记
    Python-面向对象 (二 继承)
    POJ 3518 Prime Gap(素数题)
    struts2的总体回想(ACTION、拦截器、值栈、OGNL表达式、ModelDriven方案等)
    first move advantage_百度搜索
    【绿茶书情】:《SOHO小报》和《凤…
    潘石屹的SOHO小报猝死
    ASP.NET Hashtable输出JSON格式数据
  • 原文地址:https://www.cnblogs.com/herbertchina/p/4306815.html
Copyright © 2011-2022 走看看