sharpshell
sharpshell copied to clipboard
docs: update for shell context menus
Update docs to refer to the notes in #277.
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 eachToolStripItem
.
IMO, should be Best Practice to always set a Name
, too.
`
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!