How to affect definition of COMBOBOX window class
-
24-05-2021 - |
Question
I have a subclass of CComboBox
that behaves differently in two different
contexts - both in native C++. In the working (test) context the top-level application was created
using VS2008. In the non-working case the application is greatly more complex
and was probably originally created by an earlier VS version.
In the failure case the control won't display a dropdown box, but responds to
up/down arrow key controls. Also in the failure case it always returns zero
when queried using GetMinVisible
and always returns failure from
SetMinVisibleItems
.
It appears that the problem is rooted in the definition of the COMBOBOX
window
class. I have dumped the data returned from ::GetClassInfoEx
in both cases.
Aside from the address of the wndProc
, there are two differences. First, the working
case has style CS_GLOBALCLASS
set while the failure case doesn't. Also the
working case specifies 4 bytes of extra window storage (cbWndExtra
) while the
failure case specifies 8 bytes.
So my questions are: 1) What configuration properties might affect the definition of
the COMBOBOX
window class?, and 2) How can I determine the correct wndProc to use if I make my own window class?
EDIT: The behavior of the dropdown box changes with the specification of the character set
property in the General property tab. It works as expected if character set
is unicode
and fails when it's not set
. The combo box subclass is in an ActiveX control, but the setting at the application level seems to affect the window class, which winds up messing up the combo box in ActiveX control. Interestingly there are other combo boxes, albeit in dialogs, elsewhere in the application that seem to behave just fine.
Solution
SetMinVisibleItems uses CB_SETMINVISIBLE and it requires comctl32 v6, this is your clue that this is a visual styles issue.
The older common controls version of the combobox actually uses the controls height as the size of the drop-down list so if you adjust that you might be able to fix it without adding a manifest.