现在维护的一个软件还是用mfc写的,最近被要加入一个功能弄得焦头烂额。主要现象就是加入的菜单的响应函数没被call到

上网搜索,在官方网站找到了不少资料

主要链接如下

https://msdn.microsoft.com/en-us/library/shfzay75.aspx

https://msdn.microsoft.com/en-us/library/2zdbzhex.aspx

文中介绍了一个例子

  1. The main frame window receives the command message first.

  2. The main MDI frame window gives the currently active MDI child window a chance to handle the command.

  3. The standard routing of an MDI child frame window gives its view a chance at the command before checking its own message map.

  4. The view checks its own message map first and, finding no handler, next routes the command to its associated document.

  5. The document checks its message map and finds a handler. This document member function is called and the routing stops.

最后找到一个办法,就是重载CMainFrm的OnCmdMsg函数

但比较恶心的是需要检查menu id,否则在dialog的omcmdmsg可能会回掉会mainfrm导致循环调用爆掉

BOOL CMainFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
{ if (CFrameWndEx::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo))
return TRUE; if (nID == ID_VIEW_TEST)
{
if (aboutDlg)
{
if (aboutDlg->OnCmdMsg(nID, nCode, pExtra, pHandlerInfo))
return TRUE;
}
} return FALSE;
}

MFC message routine的更多相关文章

  1. Meandering Through the Maze of MFC Message and Command Routing MFC消息路由机制分析

    Meandering Through the Maze of MFC Message and Command Routing Paul DiLascia Paul DiLascia is a free ...

  2. BEGIN_TEMPLATE_MESSAGE_MAP

    最近转做服务端开发,或多或少有点坑爹的感觉.目前正在恶补Linux C/C++编程,主要还是集中在Linux系统API的学习.不过也好,以后更新的内容不仅仅只有Windows了. 今天说一点简单的东西 ...

  3. windows消息处理(强烈推荐,收藏)

    由于看了一下,比较好理解,暂时先放到这里,待有空再翻译.只是在每节后大致介绍一下讲的内容. 感觉写的比较全,无论从消息的原理还是从MFC操作上来说,值得一看,我也在此做个收藏. (一) 说明:以下首先 ...

  4. UNREFERENCED_PARAMETER

    作用:告诉编译器,已经使用了该变量,不必检测警告! 在VC编译器下,如果您用最高级别进行编译,编译器就会很苛刻地指出您的非常细小的警告.当你生命了一个变量,而没有使用时,编译器就会报警告:" ...

  5. mysql: Error Codes and Messages

    Appendix B. Error Codes and MessagesTable of Contents B.1. Server Error Codes and MessagesB.2. Clien ...

  6. Eclipse 4.2 failed to start after TEE is installed

    ---------------  VM Arguments---------------  jvm_args: -Dosgi.requiredJavaVersion=1.6 -Dhelp.lucene ...

  7. MFC VS2005 添加Override 和 Message

    VS2005 1.Overrides OnInitDialog() 在Class View选中 这个类,然后properties中点Message 旁边的Overrides, 添加OnInitDial ...

  8. 【Windows Message】MFC 通过F5,刷新桌面

    //通过F5,刷新桌面 HWND hWndProgram = ::FindWindow( _T("Progman"), NULL); HWND hWndDefView = ::Fi ...

  9. mfc ui3

    引用:http://www.cnblogs.com/rainbowzc/archive/2010/06/02/1749872.html 本文专题讨论VC中的界面美化,适用于具有中等VC水平的读者.读者 ...

随机推荐

  1. filebeat成精之路

    https://www.cnblogs.com/jingmoxukong/p/8185321.html

  2. 中文字符utf-8编码原则

    UTF-8是一种变长字节编码方式.对于某一个字符的UTF-8编码,如果只有一个字节则其最高二进制位为0:如果是 多字节,其第一个字节从最高位开始,连续的二进制位值为1的个数决定了其编码的位数,其余各字 ...

  3. VSFTP服务配置

    FTP连接及传输模式控制连接:TCP 21 ,用于发送FTP命令信息数据连接:TCP 20 ,用于上传.下载数据数据连接的建立类型:主动模式.被动模式 主动模式:服务器主动发起数据连接·首先由客户端向 ...

  4. wx小程序 使用字体

    1.下载项目下的字体库 2.解压复制iconfont.css中的代码到,小程序 app.wxss 3.使用: //icon-begindate表示开始时间的图标 <text class=&quo ...

  5. VTP管理交换机的VLAN配置

    实验要求:将Switch1设置为VTPserver.Switch2设置为VTPtransparent.Swtich3和4设置为VTPclient 拓扑如下: 涉及内容: 1.VTP的创建 2.VTP的 ...

  6. opengl学习,一篇就够你基本了解

    http://blog.csdn.net/iduosi/article/details/7835624

  7. I.MX6 使用Ubuntu文件系统

    /********************************************************************************* * I.MX6 使用Ubuntu文 ...

  8. Linux命令学习之路——档案拷贝:cp

    使用权限:所有角色 使用方式:cp [ -arf ] source dest / cp [ -arf ] source... Directory 作用:把一个档案拷贝到另一个档案(档案复制),或将多个 ...

  9. [LeetCode&Python] Problem 283. Move Zeroes

    Given an array nums, write a function to move all 0's to the end of it while maintaining the relativ ...

  10. 四则运算V1.1

    作业:https://edu.cnblogs.com/campus/nenu/SWE2017FALL/homework/997 代码:https://coding.net/u/Dawnfox/p/f4 ...