ComboBoxEx focus bug

felix.nawothnig at t-online.de felix.nawothnig at t-online.de
Tue Apr 26 08:33:33 CDT 2005


Hi.

I'm trying to fix PR 1114 and ran into the following problem:

The listbox of WinRAR isn't updated because CBN_SELENDOK isn't sent.

CBN_SELENDOK is supposed to be sent by CBRollUp() called by the  
LBN_SELCHANGE handler but isn't because the listbox (of the combobox)  
is already rolled up when LBN_SELCHANGE is received.

The premature CBRollUp() is caused by a click into the combo/listbox  
which SetFocus()es the listbox which causes a KILLFOCUS sent to the  
edit control which was holding the focus before and then forwards the  
KILLFOCUS to it's parent (the ComboLBox) which rolls the listbox up and  
issues CBN_SELENDCANCEL.

(This causes also a visible difference between native and builtin  
comctl32 - native ComboBoxEx rolls up on mouseup, ours rolls up on  
mousedown)

So the problem is that the editbox has the focus although the listbox  
is rolled down - this is the case for DROPDOWN comboboxes but only  
possible since the listbox takes care of this special case and forwards  
the focus to the edit control.

Since a ComboBoxEx is a DROPDOWNLIST with an edit control drawn itself  
the editbox has to lose the focus when the listbox is rolled down.

The listbox code actually takes care of that and sets the focus to the  
listbox if it's not child of a DROPDOWN CB but the CBN_SETFOCUS  
handling in comboex.c sets the focus back to the edit control for some  
reason, stating:

         * We also need to set the focus back to the Edit control
         * after passing the command to the parent of the ComboEx.

Putting an "case CBN_SETFOCUS:" before the CBN_SELENDOK case (making  
sure that the focus isn't set to the edit control after a CBN_SETFOCUS)  
makes WinRAR work, makes the listbox roll up on mouseup (looks exactly  
like native comctl32) and doesn't seem to cause any problems.

However, if the ComboBoxEx receives another CBN_* (except those handled  
by case statements which all *don't* set the focus to the edit box) I  
think it will set the focus back to the edit control (although the  
listbox is still rolled down) and when the user then selects an item it  
will again roll up and send CBN_SELENDCANCEL.

So would it be right to completly remove the focus-forwarding to the  
edit control? (Since I know nothing about Win32 programming, the  
comments talk about MSIE4 expecting some specific behaviour and I don't  
wanna cause a regression I decided to ask here first :)

-flexo



More information about the wine-devel mailing list