We have a sample application with such handler for a combobox in "DropDownList" mode:
private void comboBox1_Leave(object sender, EventArgs e)
{
comboBox1.SelectionStart = 0;
comboBox1.SelectionLength = 0;
}
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.
these are few lines from exception description:
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()
The question is: What might be the cause of that different behavior with a hook installed?
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?
PS2: Application that installs the hook and a hook DLL are written in C++. Hook function is as simple as:
return (CallNextHookEx(hook_handle, code, wParam, lParam));