Set height of edit box/static text area of MFC CComboBox (not the dropdown)

641 Views Asked by At

My goal is to be able to programatically control the width and height of the combobox when it is closed (dropdown not displayed). I have various other controls, such as buttons, and I want all the controls to appear a uniform size on the dialog (say, 100 x 40). I tried calling my_cb_device.SetItemHeight(-1,40) but it doesn't seem to have any effect. Style is CBS_DROPDOWNLIST. Can anyone furnish a simple example of changing this? Does CBS_NOINTEGRALHEIGHT need to be set/not set? I've tried every combination I can think of, nothing seems to affect the height. Oddly, width is not uncooperative. Some code (note: BTN_HT is 40):

m_cb_device.Create( WS_CHILD | WS_VISIBLE | WS_TABSTOP |
    CBS_DROPDOWNLIST | WS_VSCROLL | CBS_NOINTEGRALHEIGHT,
    dummyRect, this, ID_CB_DEVICE );
populate_device_dropdown();
m_cb_device.SetItemHeight( -1, BTN_HT );
m_cb_device.SetCurSel( 0 );
m_cb_device.SetMaxVisibleLines( 32 );
0

There are 0 best solutions below