PRB: Duplicate Menu Items In the File Menu For a Shell Context Menu Extension

ID: Q214477


The information in this article applies to:


SYMPTOMS

BETA INFORMATION BETA INFORMATION BETA INFORMATION

This article discusses a Beta release of a Microsoft product. The information in this article is provided as-is and is subject to change without notice.

No formal product support is available from Microsoft for this Beta product. For information about obtaining support for a Beta release, please see the documentation included with the Beta product files, or check the Web location from which you downloaded the release.

BETA INFORMATION BETA INFORMATION BETA INFORMATION


On systems with Shell32.dll version 4.71 or higher, a context menu extension for a file folder that inserts one or more pop-up menus results in duplicates of these menu items. This occurs when the file menu is activated more than once for the selected object.


CAUSE

In a context menu extension, if pop-up menus are inserted using InsertMenu or AppendMenu, then the ID for the pop-up menu item cannot be specified. Instead, this field should take in the HMENU of the pop-up menu. Because the ID is not specified for the pop-up menu item, the Shell does not keep track of the menu item if the file menu is pulled down multiple times. As a result, the pop-up menu items are added multiple times in the context menu.

This problem occurs only when the file menu is pulled down, and does not happen when the context menu is invoked by using the right button or the context menu key.


RESOLUTION

To work around this problem, use InsertMenuItem and specify the ID of the pop-up menu item in the wID member of the MENUITEMINFO structure.

Sample code


mii.fMask = MIIM_SUBMENU | MIIM_TYPE | MIIM_CHECKMARKS | MIIM_STATE | MIIM_ID;
mii.wID = idCmdFirst++; 


STATUS

This behavior is by design.


MORE INFORMATION

Steps to Reproduce Behavior

  1. Create a Shell context menu extension for a file folder. You can use "ShellExt : Basic Shell Extension" as sample to start with.


  2. In the IContextMenu::QueryContextMenu implementation, insert a pop-up menu item using InsertMenu or AppendMenu.


  3. After the context menu extension is built, register it.


  4. Open Explorer and select a file for which the context menu is registered or select a folder.


  5. Pull down the file menu. The context menu for the object is displayed, along with the added pop-up menu.


  6. Close the menu and pull down the file menu again. The context menu for the object is displayed with two identical pop-up menu items added by the Shell Context menu extension.



REFERENCES

Additional query words:


Keywords          : kbContMenu kbExtension kbNTOS400 kbWinOS2000 kbSDKPlatform kbWinOS95 kbWinOS98 kbGrpShell 
Version           : WINDOWS:95,98
Platform          : WINDOWS 
Issue type        : kbprb 

Last Reviewed: May 19, 1999