区分不同的命令。命令消息主要来自菜单、工具栏和加速键。其中菜单和加速键
消息将是本章要学习的内容。
上面的这3 类消息在MFC 中有统一的处理框架,即消息映shè机制。消息映shè机制将消
息及其处理函数表示成一一对应的表,并对这张表进行分析处理。CCmdTarget 类的派生类用
于存放消息映shè机制,使用消息映shè必须在源程序中加入以下两方面内容:
(1)在类的头文件中加入如下语句:
DECLARE_MESSAGE_MAP()
例如在类CTestApp 的头文件TestApp.h 中有如下代码段:
class CTestApp : public CWinApp
{
public:
CTestApp();
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CTestApp)
public:
virtual BOOL InitInstance();
//}}AFX_VIRTUAL
// Implcomntation
//{{AFX_MSG(CTestApp)
afx_msg void OnAppAbout();
// NOTE - the ClassWizard will add and removecommber functions here.
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
DECLARE_MESSAGE_MAP()就添加在CTestApp 类的定义程序块的末尾。
(
松语文学免费小说阅读_www.16sy.com