Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid SelectedItem Count with > 16 items #4

Closed
dwmkerr opened this issue Nov 27, 2013 · 8 comments

Comments

@dwmkerr
Copy link
Owner

commented Nov 27, 2013

See: http://www.codeproject.com/Articles/512956/NET-Shell-Extensions-Shell-Context-Menus?msg=4710563#xx4710563xx

Hey,

when I'm right-clicking on more than 16 selected files and/or directories for the first time, my context menu handler don't show up on each file/directory as I'd expect. I found out that this happens because at the very beginning the selectedItem count is somehow set to 16, although I have selected a lot more than 16 files and/or directories. But when I click on the handler of one of the file/directory which shows the menu, the selectedItem count is set to the real number of elements I have selected.

Do you have any suggestion why this happens or what I could do to avoid this behaviour?

Thanks!!

@dwmkerr dwmkerr added this to the Release 2.2 milestone Feb 15, 2014

@dwmkerr dwmkerr self-assigned this Feb 15, 2014

@dwmkerr

This comment has been minimized.

Copy link
Owner Author

commented Mar 3, 2014

I have just tested and confirmed this behaviour on Windows 8 - with IShellExtInit we don't get more than 16 items, seems to be an optimisation in windows.

@dwmkerr

This comment has been minimized.

Copy link
Owner Author

commented Mar 24, 2014

More details:

http://msdn.microsoft.com/en-us/library/dd758093%28VS.85%29.aspx[^]

In Windows 7 and later, the number of items passed to a verb is limited to 16 when a shortcut menu is queried. The verb is then re-created and re-initialized with the full selection when that verb is invoked.

See: http://www.codeproject.com/Articles/512956/NET-Shell-Extensions-Shell-Context-Menus?msg=4783716#xx4783716xx

@seguso

This comment has been minimized.

Copy link

commented Oct 8, 2014

Hello, sorry, but reading the above I don't understand if it is currently possible with SharpShell to receive more than 16 files in a context menu. Please help.

@dwmkerr

This comment has been minimized.

Copy link
Owner Author

commented Oct 10, 2014

It is possible, the only problem is that you only see 16 items when the verb is queried - once it verb is actually invoked you get the full set of items

@seguso

This comment has been minimized.

Copy link

commented Oct 10, 2014

Dave, thanks for the response. Unfortunately, in my tests, if there are more than 16 items selected in explorer, the click event handler is not called at all.

var tagItem = new ToolStripMenuItem { Text = stringaTag, Image = Icons.tag_16x16 };
tagItem.Click += (sender, e) =>
{
log("debug"); // NEVER GETS HERE if there are more than 16 items selected
};
menu.Items.Add(tagItem);

it works properly if you select fewer items.

Any suggestions? Thanks again.

@dwmkerr

This comment has been minimized.

Copy link
Owner Author

commented Oct 14, 2014

Hi @seguso at the moment I'm flat out of suggestions, this has been an extremely problematic issue to fix, you could try looking at the links mentioned earlier in this thread and see if anything suggests itself to you. I'll try and build a test case around this soon but that will mean only that I can reproduce the problem more easily, not that I can necessarily fix it

@dwmkerr dwmkerr modified the milestones: Backlog, Release 2.2 Nov 29, 2014

@Miki101

This comment has been minimized.

Copy link

commented Oct 14, 2018

@dwmkerr

This comment has been minimized.

Copy link
Owner Author

commented Oct 16, 2018

Thanks @Miki101! Some notes from my own recent investigation. When running the 'Count Lines' sample on Windows 10, the handler is shown:

image

The handler is also called successfully with the correct set of files:

image

This is without:

HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\MultipleInvokePromptMinimum

set. However, I'm going to update the docs with the links to this article and the associated issue on MSDN before I close this. Thanks for letting me know @Miki101 !

dwmkerr added a commit that referenced this issue Oct 16, 2018
docs: context menu troubleshooting
Updated the old CodePlex docs to markdown, added a note on limitations
with Context Menus when working with more than 15 items. Closes #4.

@dwmkerr dwmkerr closed this in #185 Oct 16, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.