noober
noober

Reputation: 4938

Windows Explorer context menu item ids

Using ::GetMenuItemInfo() I see that on my Win 8.1 x 64 'Delete' menu item ID is equal to decimal 18 and 'Properties' ID is equal to 20. Are they the same on any Windows and where are they defined in the SDK headers?

UPDATE

I'd like to use TrackPopupMenu to show the system menu for some files inside my app, but I want to override some of items such as 'Delete'. How can I check whether an item #i (where i is an index from 0 to item count) is the 'Delete' item to change its id to my own and handle it later? If IDs are constant, it seems to be pretty simple, but otherwise...

Upvotes: 0

Views: 425

Answers (1)

Denis Anisimov
Denis Anisimov

Reputation: 3317

Don`t use menu item ID for command identification. Command IDs can be different in different time even on the same PC. If you want to override any menu item you must analyse verb of command instead of ID. Verbs are always the same.

When you have IContextMenu of object enum menu items and call IContextMenu.GetCommandString function with GCS_VERBA or GCS_VERBW parameter. When GetCommandString return you 'delete' string - at this position you have Delete command. When GetCommandString return you 'properties' string - at this position you have Properties command.

Upvotes: 4

Related Questions