Nous avons un exemple d'application avec un tel gestionnaire pour un combobox en mode "DropDownList":comportement étrange causés par l'utilisation des propriétés ComboBox .Net selectionStart & SelectionLength en mode "DropDownList"
private void comboBox1_Leave(object sender, EventArgs e)
{
comboBox1.SelectionStart = 0;
comboBox1.SelectionLength = 0;
}
le code se comporte au-dessus différemment selon si l'application a le crochet CALLWNDPROC chargé ou pas. Si l'application a un hook CALLWNDPROC dedans - le code ci-dessus jetterait une exception quand combobox perd le focus. Sans le crochet - ce code ne jette pas.
ce sont quelques lignes de description d'exception:
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()
La question est: Quelle pourrait être la cause de ce comportement différent avec un crochet installé? PS1: Je ne suis pas un développeur C#, mais il me semble que le concept de sélection textuelle ne s'applique pas aux comboboxes DropDownList (car elles n'ont pas de textbox), est-ce correct? PS2: L'application qui installe le hook et une DLL hook sont écrites en C++. fonction Hook est aussi simple que:
return (CallNextHookEx(hook_handle, code, wParam, lParam));