The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

Hook into right click menu of an application?

A customer requests a feature for my application. He wants to be able to select the text in applications such as Word or IE, select a menu item (installed by my program), and my program pops up and intercepts this text.
I remember that a couple of years ago Micrsoft had a software called BookShelf. Once the Bookshelf is installe, new menu item appears when you select words in Microsoft Word. I can activate bookshelf by selecting the memnu. I can not remember if it works on other applications.
Question: is it possible to install custom menu items into another application? if it is possible can anyone give some hints about the implement? Your input is appreciated.
MFC Programmer
Wednesday, August 17, 2005
There are two ways AFAIK to do this:

1) Shell extension
2) Dynamic memory hook

The first method consists of registering a dll that modifies context menus. The second method has your program permanently hiding in the background and change context menus when they get created, but before they're painted.

Michael Dunn wrote a great series about shell extensions, highly recommended reading.

Good luck
General Protection Fault
Wednesday, August 17, 2005
If the menu is added in Word, the most likely is that they used VBA and a startup script (in to hook it there. This is what Acrobat does to add its menu and buttons to Word AFAIK.
This is very different from Shell extensions (which work only in Explorer) and from hooks (which are probably what you need if do not want to restrict your special menu to Word/Office or Explorer only).
Wednesday, August 17, 2005
Internet Explorer has it's own method for adding items to right-click menus that involves adding a few registry keys.  You should be able to find information for it on the web.

For Word, using VBA seems the logical method.
Almost H. Anonymous Send private email
Thursday, August 18, 2005
Yeah, you're absolutely right.

When I wrote my earlier message I thought it made little sense already, but I didn't take time to think it through.

Apologies for the false suggestion, Shell Extensions, although cool, won't be of any use here.
General Protection Fault
Thursday, August 18, 2005
You need to create an Addin for MS word. This is simple in VB - just create a new Addin project and change the (target) Application to be Word (or one of the other Office apps).

Getting it to add context menus is not horrendous work, but you do have to know what you're doing or face hours of fun. Google for samples.

IE - Can't remember. I did this years ago for something and I think previous poster is correct; it involves the registry.

Sorry, I don't speak MFC - and this PC doesn't have VC on it to go and check.
Justin Send private email
Saturday, August 20, 2005

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
Powered by FogBugz