How to gray out some context-menu options with an IExecuteCommand-based shell extension?

强颜欢笑 提交于 2019-12-23 01:57:13

问题


When implementing a context-menu shell extension using the IExecuteCommand approach (as described in this blog post), how can a given menu option be grayed out?

E.g. Suppose that the shell extension offers some menu options, and some of them should be grayed out basing on some state and conditions that the shell extension computes, for example: if the user right-clicks on a file and the shell extension detects that this file has some given properties, some of the shell extension context menu options should be grayed out.

How to do that using IExecuteCommand?

Or should another Windows Shell COM interface be used for that purpose?


回答1:


I have never tried this but you should be able to set CommandState­Handler (undocumented?) in your verb's key to a CLSID that implements IExplorerCommandState.

You might also think about implementing IExplorerCommand instead of IExecuteCommand+IExplorerCommandState...

You can also hide verbs based on a query to the property system with the AppliesTo value.



来源:https://stackoverflow.com/questions/28197401/how-to-gray-out-some-context-menu-options-with-an-iexecutecommand-based-shell-ex

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!