子类(或钩子)正在进行的菜单? [英] Subclass (or hook) a menu that is in-process?

查看:66
本文介绍了子类(或钩子)正在进行的菜单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





有许多不在线的菜单挂钩解决方案以及如何添加物品等。

但我可以'在网上找不到我想要的东西,也不知道是否可能。



我的代码是用c ++编写的主机应用程序的com插件。它正在进行中。



我必须(如果可能的话)知道用户何时单击文件,保存或另存为以便我可以做一些工作代码中的
。插件API没有这样的通知所以我必须偷偷摸摸。



我有一个应用程序窗口的句柄和一个HMENU到它从GetMenu()获得的菜单。



我知道如何进行子类化但是如何在进程中监视菜单的正确方法?



任何人都可以指出我正确的方向,所以我不会浪费一周或更长时间。 :-)



谢谢,



:Ron

Hi,

There are many out of process menu hooking solutions and how to add items and such.
But I can''t find what I want on the net, nor know if it is possible.

My code is a com plug-in for a host application written in c++. it''s in-process.

I must (if possible) know when the user clicks File,Save or Save As so I can do some work
in the code. The plug-in API has no such notification so I have to be "sneaky".

I have a handle to the application''s windows and an HMENU to it''s menu obtained from GetMenu().

I know how to subclass but how is the proper way to "spy" on a menu in-process?

Can anyone point me in the correct direction so I don''t waste a week or more. :-)

Thanks,

:Ron

推荐答案

原则上,答案不是窥探或挂钩菜单,这可能是困难的,而是钩住在您感兴趣的文件菜单项时选择生成的命令消息。这可以通过全局消息挂钩来完成。如果我没记错的话,你需要的钩子类型叫做 CBT Hook 。搜索这些术语可以满足您的需求。自从我上次使用管理控制台的进程COM插件以来已经过去了11年。它当时工作,我希望它仍然会受到足够高的权限来安装钩子。

如果你认为这还不够,你想要完全控制整个菜单那么我知道的最好的例子在 ProfUIS GUI框架中实现完整的菜单子类化,包括未记录的类ID'。我不建议从那条路开始,除非绝对没有别的方法,钩子应该适用于任何短的完整菜单更换。
In principle the answer is not to spy on or hook the menu which is possible but difficult but rather to hook the command messages generated when the File menu items you''re interested in are selected. This can be done with a Global Message Hook. If I remember correctly the type of hook you need is called a CBT Hook. A search for these terms should get you what you need. It''s 11 years since I last did that with an in process COM plugin for the Management Console. It worked then and I expect it still will subject to elevated enough permissions to install the hook.
If you decide this is not enough and you want full control of the entire menu then the best example I know for full Subclassing of menus including the undocumented class id''s required is implemented in the ProfUIS GUI framework. I wouldn''t recommend starting down that road though unless there is absolutely no other way, hooks should work for anything short of complete menu replacement.


这篇关于子类(或钩子)正在进行的菜单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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