I have ON_COMMAND and ON_UPDATE_COMMAND_UI handlers for menu items in an MFC dll. But they are not invoked. The same code compiled as .exe has the handlers being invoked. What could be the reason for this?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
ON_UPDATE_COMMAND_UI and ON_COMMAND handler are only called when the object that contains the handler is within the command routing.
So the DLL itself isn't the problem but also this depends on how you created your DLL. For a standard DLL and without sharing the MFC as a DLL this will not work at all. AFAIK to get it run the DLL should be an extension DLL loaded into the application. The reason is that the main application wil not recognize your objects in a standard DLL when the MFC is statically linked.
Read more about command routing in the MSDN and in the technical notes