The QueryContextMenu method adds the new menu items to a context menu.
HRESULT QueryContextMenu ( HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags );
[in] The menu to which additional items are added.
[in] Specifies the location on the menu (must never be –1).
[in] The beginning of the specified range.
[in] The end of the specified range.
[in] Specifies the context. See the Remarks section for the list of supported flags.
QueryContextMenu returns the number of items that were added to the context menu. The number of items added is also the maximum menu item ID offset (USHORT) in the code field (LOWORD) of the scode.
Note If there are gaps between menu items, the number is provided as if there were no gaps.
The QueryContextMenu method can insert one or more new menu items into the specified menu hmenu, at the specified location indexMenu, with the IDs of those menu items. IDs must be in the range specified from idCmdFirst to idCmdLast. The QueryContextMenu method returns the maximum menu item ID offset (USHORT) in the code field (LOWORD) of the scode. The HIWORD is reserved for context specific communications, and the LOWORD is reserved for system use. The uFlags parameter specifies the context of the invocation.
The following table lists the possible values for the uFlags parameter.
|CMF_NORMAL||0x00000000||Passed when the user right-clicks or taps and holds an object in the content pane. This is referred to as the normal action. Note that a shortcut menu extension, namespace extension, or drag-and-drop handler can add all menu items.|
|CMF_DEFAULTONLY||0x00000001||Passed when the user double-clicks or taps an object in the content pane. This is referred to as the default action. QueryContextMenu returns NOERROR, and no menu items are added to the context menu.|
|CMF_VERBSONLY||0x00000002||Passed when constructing a context menu for a short-cut object. QueryContextMenu never adds unsuitable menu items to context menus. An example of an unsuitable menu item is Delete, because it is not clear whether Delete should remove the link source item or just the link.|
|CMF_EXPLORE||0x00000004||Passed when the user right-clicks or taps and holds an object in the navigation pane. This flag is ignored.|
Pocket PC: Pocket PC 2000 and later.
OS Versions: Windows CE 3.0 and later.
Header: Declared in shlobj.h.
Send Feedback on this topic to the authors