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



The information in this article applies to:

  • Microsoft Platform Software Development Kit (SDK) 1.0, when used with:
    • Microsoft Windows 98
    • Microsoft Windows 95
    • Microsoft Windows NT Server 4.0
    • Microsoft Windows NT Workstation 4.0
    • the operating system: Microsoft Windows 2000

This article was previously published under Q214477

SYMPTOMS

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 how to obtain support for a Beta release, see the documentation that is included with the Beta product files, or check the Web location from which you downloaded the release.

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


Modification Type:MinorLast Reviewed:7/11/2005
Keywords:kbContMenu kbExtension kbprb KB214477