Note that there are some explanatory texts on larger screens.

plurals
  1. POWeird behavior caused by using .Net ComboBox properties SelectionStart & SelectionLength in "DropDownList" mode
    text
    copied!<p>We have a sample application with such handler for a combobox in "DropDownList" mode:</p> <pre><code> private void comboBox1_Leave(object sender, EventArgs e) { comboBox1.SelectionStart = 0; comboBox1.SelectionLength = 0; } </code></pre> <p>the code above behaves differently depending whether the application has CALLWNDPROC hook loaded or not. If application has a CALLWNDPROC hook in it - the code above would throw exception whenever combobox loses focus. Without the hook - that code doesn't throw.</p> <p>these are few lines from exception description:</p> <pre><code>System.ArgumentOutOfRangeException: InvalidArgument=Value of '-2136611475' is not valid for 'start'. Parameter name: start at System.Windows.Forms.ComboBox.Select(Int32 start, Int32 length) at System.Windows.Forms.ComboBox.set_SelectionLength(Int32 value) at ComboCrash.Form1.comboBox1_Leave(Object sender, EventArgs e) in T:\tmp.proj\ComboCrash\ComboCrash\Form1.cs:line 32 at System.Windows.Forms.Control.OnLeave(EventArgs e) at System.Windows.Forms.Control.NotifyLeave() at System.Windows.Forms.ContainerControl.UpdateFocusedControl() </code></pre> <p>The question is: What might be the cause of that different behavior with a hook installed?</p> <p>PS1: I am not a C# developer, but it seems to me that concept of textual selection is not applicable for DropDownList comboboxes (as they don't have a textbox), is it correct? </p> <p>PS2: Application that installs the hook and a hook DLL are written in C++. Hook function is as simple as: </p> <pre><code>return (CallNextHookEx(hook_handle, code, wParam, lParam)); </code></pre>
 

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