Setting the DropDown height of a ComboBox using the Win32 API with Common Controls 6.0
Question
Friday, December 27, 2013 11:15 PM
Prior to using Common Controls 6.0 (Windows 7) we could calcaluate the height of a ComboBox DropDown by multiplying the number of rows we wanted to be visible by the row height, adding in margins. We then did a SendMessage to the control passing it a WM_SIZE message, SIZENORMAL, and a lparam which had the desired width height encoded into it. This worked well. We are now having problems with the same code under Windows 7. The dropdown height remains unchanged no matter what we set it to (it seems to be based on the number of rows in the entire data set).
Research showed me things such as the CB_SETMINVISIBLE message, which works, but I need to actually do something more like a CB_SETMAXVISIBLE (which doesn't exist!). How do I under program control set the height of a ComboBox DropDown to a given number of rows ( like I would like to only see 10 out of a data set of 100, with a scrollbar to move within the data set).
Thanks,
Don
All replies (2)
Saturday, December 28, 2013 12:58 AM âś…Answered
Simply resize the combobox with MoveWindow or SetWindowPos to a desired height. Perhaps surprisingly, this doesn't actually resize the "main" portion of the combobox, but only its drop-down list.
By manually sending it WM_SIZE notification, I think you were exploiting an implementation detail. SetWindowPos et al, of course, also send WM_SIZE (among other things). Perhaps the combobox used to resize the drop-down in response to that notification, but doesn't anymore.
Igor Tandetnik
Monday, December 30, 2013 5:26 AM
I would like to only see 10 out of a data set of 100, with a scrollbar to move within the data set
Why can't you use CB_SETMINVISIBLE with 10?
Thanks, Renjith V R