sharpshell icon indicating copy to clipboard operation
sharpshell copied to clipboard

docs: update for shell context menus

Open dwmkerr opened this issue 5 years ago • 2 comments

Update docs to refer to the notes in #277.

dwmkerr avatar Apr 08 '19 12:04 dwmkerr

Originally refers to issue #272 Also refers to PR #273

From #272:

Now, a few clarifications to the "duplicated menus issue": The way Windows decides if two items are actually the same and should show only one is the VERB. So if we set the same verb for an item when creating the Directory and DirectoryBackgroud menus it will be shown only once. For VERB, SharpContextMenu uses the ToolStripItem.Name property if set, otherwise it generates a unique one. That's why the static MenuStrip workaround works, but if the menu should be dynamic we just need to set ToolStripItem.Name and we are fine. It will be good to include that info in the documentation.

Documenting a way to handle the "doubled context menu items" issue:

  • Set property Name of each ToolStripItem.

IMO, should be Best Practice to always set a Name, too. `

Countryen avatar Apr 09 '19 19:04 Countryen

I resolved this issue a while back with my own application by doing the following which can be found at:

https://github.com/dwmkerr/sharpshell/issues/140#issuecomment-485257032

Solution is to add in SharpContextMenu.cs in IContextMenu.QueryContextMenu this piece of code to filter it:

// Don't show for Windows 10 Quick Access // Returns: CMF_EXPLORE (0x00000004), CMF_CANRENAME (0x00000010), CMF_ASYNCVERBSTATE (0x00000400) if (Convert.ToInt32(uFlags) == 1044) { return WinError.S_FALSE; }

Keep in mind that this will hide both from Quick Access which is what I personally wanted. I just add the returns into a single integer and if it matches then don't show.

EDIT: After reading all of the comments on this issue (sorry, I missed the few that actually had the answer), Adding the name property does solve this issue. THANK YOU!

xCONFLiCTiONx avatar Apr 21 '19 14:04 xCONFLiCTiONx