MFC message routine
现在维护的一个软件还是用mfc写的,最近被要加入一个功能弄得焦头烂额。主要现象就是加入的菜单的响应函数没被call到
上网搜索,在官方网站找到了不少资料
主要链接如下
https://msdn.microsoft.com/en-us/library/shfzay75.aspx
https://msdn.microsoft.com/en-us/library/2zdbzhex.aspx
文中介绍了一个例子
The main frame window receives the command message first.
The main MDI frame window gives the currently active MDI child window a chance to handle the command.
The standard routing of an MDI child frame window gives its view a chance at the command before checking its own message map.
The view checks its own message map first and, finding no handler, next routes the command to its associated document.
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的更多相关文章
- 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 ...
- BEGIN_TEMPLATE_MESSAGE_MAP
最近转做服务端开发,或多或少有点坑爹的感觉.目前正在恶补Linux C/C++编程,主要还是集中在Linux系统API的学习.不过也好,以后更新的内容不仅仅只有Windows了. 今天说一点简单的东西 ...
- windows消息处理(强烈推荐,收藏)
由于看了一下,比较好理解,暂时先放到这里,待有空再翻译.只是在每节后大致介绍一下讲的内容. 感觉写的比较全,无论从消息的原理还是从MFC操作上来说,值得一看,我也在此做个收藏. (一) 说明:以下首先 ...
- UNREFERENCED_PARAMETER
作用:告诉编译器,已经使用了该变量,不必检测警告! 在VC编译器下,如果您用最高级别进行编译,编译器就会很苛刻地指出您的非常细小的警告.当你生命了一个变量,而没有使用时,编译器就会报警告:" ...
- mysql: Error Codes and Messages
Appendix B. Error Codes and MessagesTable of Contents B.1. Server Error Codes and MessagesB.2. Clien ...
- Eclipse 4.2 failed to start after TEE is installed
--------------- VM Arguments--------------- jvm_args: -Dosgi.requiredJavaVersion=1.6 -Dhelp.lucene ...
- MFC VS2005 添加Override 和 Message
VS2005 1.Overrides OnInitDialog() 在Class View选中 这个类,然后properties中点Message 旁边的Overrides, 添加OnInitDial ...
- 【Windows Message】MFC 通过F5,刷新桌面
//通过F5,刷新桌面 HWND hWndProgram = ::FindWindow( _T("Progman"), NULL); HWND hWndDefView = ::Fi ...
- mfc ui3
引用:http://www.cnblogs.com/rainbowzc/archive/2010/06/02/1749872.html 本文专题讨论VC中的界面美化,适用于具有中等VC水平的读者.读者 ...
随机推荐
- Java类库和常用类库介绍
Java 类库概念: Java 的应用程序接口 (API) 以包的形式来组织,每个包提供了大量的相关类.接口和异常处理类,这些包的集合就是 Java 的类库 包名以 Java 开始的包是 Java 核 ...
- 第四周四则运算3 PSP表格
PSP2.1 Personal Software Process Stages time Plan 计划 -Estimate 整数四则运算 分数四则运算 括号 括号四则运算 在主函数中调用 30m ...
- 20165214 学习基础与C语言基础调查
读后感 我花时间仔细阅读了娄老师公众号上的那5篇关于自己各个方面学习经历的文章,随后深为震撼又自愧不如. 我实在没想到,这套学习方法竟有如此巨大的力量!纵使在娄老师不熟悉的乒乓球领域,娄老师也能通过这 ...
- 使用generator生成dao、mapping和model
我们在ssm框架开发的时候(不限于此框架),为了开发效率.有时候不得不提高一下代码速度.千篇一律的事情谁都头疼,比如写dao,写model,写mapping等等.不仅慢,而且一不留神,还会出错. 今天 ...
- ajax异步上传图片(TP5)
直接上代码 PHP代码如下 /** * 上传 */ public function upload_photo(){ $file = $this->request->file('file') ...
- diary of laravel
1. 修改数据库连接 初始化数据库: 首先: 修改 config- database.php 中的 数据库链接 其次:修改 .env 中数据库链接 创建表: php artisan migr ...
- HDU 6059 17多校3 Kanade's trio(字典树)
Problem Description Give you an array A[1..n],you need to calculate how many tuples (i,j,k) satisfy ...
- 【Python】Excel-4(样式设置)
#练习: #封装一个ExcelUtil的模块(构造函数是excel的路径),里面提供封装的方法: #1 获取某个sheet对象 #2 打印所有sheet名称 #3 给某个sheet的某个单元格写入内容 ...
- 索引rebuild与rebuild online区别
索引rebuild与rebuild online区别 1.0目的,本篇文档探讨索引rebuild 与 rebuild online的区别 2.0猜测:已有的知识 2.1对索引rebuild重建会对表申 ...
- 【leetcode】344. Reverse String
problem 344. Reverse String solution: class Solution { public: void reverseString(vector<char> ...