Note that there are some explanatory texts on larger screens.

plurals
  1. POVery strange behavior with WinForms ListBox and Ctrl+C keypress
    primarykey
    data
    text
    <p>I'm experiencing some very strange behavior in a WinForms <code>ListBox</code> in two of my applications. They both have some other controls (<code>TableLayoutPanel</code>s, <code>Button</code>s, etc.)</p> <p>Both applications handle the Ctrl+C keystroke to copy the selected item(s) of the <code>ListBox</code> to the clipboard. When I press Ctrl+C, though, the selected index of the current <code>ListBox</code> moves down by one, or if the last item is selected, the selection wraps around to the first item. This happens <em>after</em> my <code>KeyDown</code> handler does its work.</p> <p>This is very strange because there's no code in either application that would cause this behavior. I don't even know what key to press to make the selection advance or wrap like that.</p> <p>I've been trying to reproduce this behavior in a sample program, but so far I haven't been able to figure out what these two applications have in common that makes them behave this way. If I figure it out, I will update this question accordingly.</p> <p>I compared the Windows message activity between an application that has this problem and an application that doesn't. I found one specific message that is causing it:</p> <pre><code>msg=0x2111 (WM_REFLECT + WM_COMMAND) hwnd=0x211e2 wparam=0x111e2 lparam=0x211e2 result=0x0 </code></pre> <p>Here are the full message logs from pressing Ctrl+C in each program:</p> <ul> <li>Message log WITH this problem: <a href="https://gist.github.com/2854221" rel="nofollow">https://gist.github.com/2854221</a></li> <li>Message log WITHOUT this problem: <a href="https://gist.github.com/2854203" rel="nofollow">https://gist.github.com/2854203</a></li> </ul> <p>I can prevent this mystery message from being handled, but what is it, and what causes it to be sent? I'm stumped.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload