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

     
  • 相关阅读:
    java 分割
    我就骂你了,我tm还想打你呢
    就两个人,怎么搞管理?
    年底得了个公司奖金,但是我却高兴不起来
    Microsoft.VisualStudio.TestTools.UnitTesting 命名空间
    Python2.7.6标准库内建函数
    几种xml读取方法比较
    无论怎么样都不能成为你对别人发脾气的理由
    【产品策划】在移动互联网时代的多媒体社交
    DES加密 超详解 及 C++编程实现
  • 原文地址:https://www.cnblogs.com/herbertchina/p/4306815.html
Copyright © 2011-2022 走看看