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;
    };

     
  • 相关阅读:
    readLine读取socket流的时候产生了阻塞
    Netty开发UDP协议
    Netty关闭客户端
    GIT 回退出错 Unlink of file 'xx' failed. Should I try again? (y/n) 解决办法
    linux 安全狗安装问题
    linux连接mysql命令
    CentOS7 64位下MySQL5.7安装与配置(YUM)
    nginx已经启动 无法访问页面
    Linux系统下我的/etc/sysconfig/路径下无iptables文件
    CentOS 7 下安装 Nginx
  • 原文地址:https://www.cnblogs.com/herbertchina/p/4306815.html
Copyright © 2011-2022 走看看