Click here to Skip to main content
15,890,399 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted

1 solution

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.
 
Share this answer
 
Comments
Ron Anders 6-Mar-13 22:19pm    
Thanks a bunch Matt.
It looks like what I need to do. <Thumbs up>

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900