What is the difference between CMF_NODEFAULT and CMF_DONOTPICKDEFAULT?

70 views Asked by At

It seems to me like they do the same thing (tell QueryContextMenu to not call SetMenuDefaultItem).

For CMF_NODEFAULT, MSDN says "No item in the menu has been set as the default" which is a bit of a weird phrasing because the flag is a simple integer input parameter, it is not a pointer that can return a result you can check for. It goes on to say "A namespace extension should not set any of the menu items as the default". As a wild shot in the dark, this might perhaps be related to DFM_MERGECONTEXTMENU?

CMF_DONOTPICKDEFAULT which was added much later (Windows 7) all the documentation says is "When no verb is explicitly specified, do not use a default verb in its place". This is also strange because QueryContextMenu does not know if there is an explicitly specified verb or not, IContextMenu is not informed about the verb until InvokeCommand is called and by that time, the desired verb is already set in CMINVOKECOMMANDINFO. "verb explicitly specified" in context apparently means that the verbs QueryContextMenu knows about has an explicit default.

I don't see how it could be related to ShellExecuteEx and SEE_MASK_INVOKEIDLIST. If ShellExecuteEx is called without a verb, it wants IContextMenu to pick a default. If it is called with a verb, it is going to use that verb when calling InvokeCommand regardless of what the menu set as the default.

If I call GetUIObjectOf on the stock filesystem IShellFolder, the IContextMenu I get treats CMF_NODEFAULT and CMF_DONOTPICKDEFAULT the same, either of them being set causes QueryContextMenu to not call SetMenuDefaultItem.

Questions:

  • What is the difference between the two flags and where does the difference matter?

  • If I'm using IContextMenu to display a menu in my application, when (if ever) would these flags be useful?

  • If I'm implementing IContextMenu, do I treat these flags differently in my QueryContextMenu?

0

There are 0 answers