How does CanShowMenu() work?

Aug 21, 2013 at 8:32 PM
I pretty much have an context menu app built with SharpShell. The problem is CanShowMenu() does not seem seem to be getting called from the base class. Currently I changed to to return 'false' in all cases:

protected override bool CanShowMenu()
{
return false;
}

but it still shows the context menu. Any suggestions? Am I missing something?

Thank you for a great product!

Warren
Coordinator
Aug 22, 2013 at 2:33 PM
Hi,

That's strange - what have you got as the ComServerAssociations?
Aug 22, 2013 at 3:50 PM
Edited Aug 22, 2013 at 8:17 PM
[ComVisible(true)]
[COMServerAssociation(AssociationType.ClassOfExtension, ".dgn", ".cel", ".dwg")]


Warren
Coordinator
Sep 11, 2013 at 6:28 PM
Can you try downloading the latest source code and seeing if it works with that? I've been running regression tests and it seems to be fine currently. If so, I'll close this discussion with the release of 2.0
Dec 24, 2013 at 1:45 AM
Hi,

i had the same problem and fixed it in SharpContextMenu.cs function QueryContextMenu in the try - Block...
                ToolStripItemCollection itemsToShow = new ToolStripItemCollection(new ToolStrip(), new ToolStripItem[]{});
                foreach(ToolStripItem item in contextMenuStrip.Value.Items) // check every single item...
                {
                    if(this.CanShowMenu(item)) //<--- this needs an interface (of abstract class) change! -> 
                                                            // I didn't handed the item in, but it would make more sense with it
                    {
                        itemsToShow.Add(item); // the item to show in context menu
                    }
                }

                nativeContextMenuWrapper.ResetNativeContextMenu();
                lastItemId = nativeContextMenuWrapper.BuildNativeContextMenu(hMenu, firstItemId,
                    itemsToShow);
it is not a perfect solution, but it solved my problem... btw.: cool project and good job!

regards, Daniel
Coordinator
Dec 30, 2013 at 1:47 PM
Looks great Daniel - thanks for taking the time to comment, I'll see if I can get this into the next release! See:

https://github.com/dwmkerr/sharpshell/issues/5

for progress