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 · 9 comments
Closed

Invalid SelectedItem Count with > 16 items #4

dwmkerr opened this issue Nov 27, 2013 · 9 comments
Assignees
Labels
critical-todo critical bug/problem that the devs need to work on
Milestone

Comments

@dwmkerr
Copy link
Owner

dwmkerr 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
Copy link
Owner Author

dwmkerr 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
Copy link
Owner Author

dwmkerr 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
Copy link

seguso 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
Copy link
Owner Author

dwmkerr 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
Copy link

seguso 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
Copy link
Owner Author

dwmkerr 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
Copy link

Miki101 commented Oct 14, 2018

A little bit of a necro-post, but take a look at this article.
https://www.sevenforums.com/tutorials/131470-context-menu-items-missing-fix-when-more-than-15-files-selected.html

@dwmkerr
Copy link
Owner Author

dwmkerr 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
Updated the old CodePlex docs to markdown, added a note on limitations
with Context Menus when working with more than 15 items. Closes #4.
@jleveille1337
Copy link

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.

In the recent post I made as issue #353, I have cited what appears to me to be the very same problem as seguso mentioned back in Oct 2014. When I write my code to construct a collection of submenu items, I do get the onclick event, whereas seguso indicated that he never gets the call to his event handler. Sadly, when I get the call to my event handler it is the wrong submenu item! My nested menu is a hierarchy of folders that has hundreds of menu items. I choose a submenu which happens to be item 192 and the callback is sent to the event handler for submenu item number 10. It ends up looking to the end user like they clicked on the wrong menu item.

I can see that my code is invoked with 16 items on right mouse click and then my code is invoked with 20 items upon mouse click. There is actually no problem for me on that account. My issue is that the calling code (sharp shell) is telling me that someone clicked menu item number 10 when the user actually clicked item number 192. Can I get some help with this particular point either here or in issue #353?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
critical-todo critical bug/problem that the devs need to work on
Projects
None yet
Development

No branches or pull requests

4 participants