ON_COMMAND未调用处理程序 [英] ON_COMMAND not invoking handler

查看:104
本文介绍了ON_COMMAND未调用处理程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在主工具栏上添加了一个图标.资源文件具有此新按钮"的条目. ON_UPDATE_COMMAND正常工作,但ON_COMMAND似乎在某处短路.我在调试中添加了一个断点,并设法捕获了处理正确nID的ON_COMMAND代码,但是在分支到没有源代码的区域之前,无法跟踪执行情况.最重要的是,永远不会执行处理程序代码.知道为什么会是这种情况吗? ON_COMMAND语句和ON_UPDATE_COMMAND语句均在代码的MESSAGE_MAP区域中.处理程序在C ++ rtn的头文件中定义.一切都能编译和链接,而不会出现错误或警告.我相信我已经涵盖了显而易见的基础,但显然我至少错过了一个基础.

I have added an icon to the main toolbar. The resource files have entries for this new "button". The ON_UPDATE_COMMAND works just fine but the ON_COMMAND seems to short circuit somewhere. I added a breakpoint in debug and managed to catch the ON_COMMAND code processing the correct nID but wasn''t able to follow the execution very far before it branched off into an area where no source code existed. Bottom line is that the handler code is never executed. Any idea why this might be the case? The ON_COMMAND statement and the ON_UPDATE_COMMAND statement are both in the MESSAGE_MAP area of the code. The handler is defined in the header file of the C++ rtn. Everything compiles and links without errors or warnings. I believe I have covered the obvious bases but clearly I have missed at least one.

推荐答案

您是否已将afx_msg处理程序添加到您的类中(通过ClassWizard)?

尝试寻找
Did you add the afx_msg handler to your class (via the ClassWizard)??

Try to look for the
ON_COMMAND(ID_YOURCOMMAND, Function_To_CALL)


这篇关于ON_COMMAND未调用处理程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆