[MFC] Resize CComboBox drop down list based on contents

I had this post in my draft for a long time. This code snippet resizes a combo box’s drop down list. Please note an application sends the CB_SETDROPPEDWIDTH message to set the minimum allowable width, in pixels, of the list box of a combo box with the CBS_DROPDOWN or CBS_DROPDOWNLIST style. Note: MFC function CComboBox::SetDroppedWidth […]
Continue reading…

 

Some issues when working with ComboBox

The main reason for posting this issue is to help MFC/Win32 beginners. But anyway it’s a good read ;), so once upon a time… If you’re a beginner with window’s ComboBox controls then you might end up with a bald head thinking and thinking about a weird behavior of combo’s after it’s creation. The combo […]
Continue reading…

 

Add horizontal scrollbar to a combo box

CComboBox has a function called SetHorizontalExtent which doesn’t work. SDK equivalent is CB_SETHORIZONTALEXTENT which also doesn’t work. The reason for this bug is pretty lame, because WS_HSCROLL style for combo box is not set, which in turn the VS dialog editor does not provide :(. So a workaround is to open .rc file in a […]
Continue reading…

 

To retrieve ComboBox information!

We know that a combobox is a combination of different controls. Well now the question is there an API to get ample information on these controls nested in a combo?  The answer is yes, use GetComboBoxInfo. Takes a COMBOBOXINFO pointer as parameter and on return will hold necessary information… Usage: [sourcecode language=’cpp’]COMBOBOXINFO CmbInfo = { […]
Continue reading…