Cannot change the height of a combo box in the VS Dialog Editor
Any combo box I create seems to be stuck at 12 dialog units in height. Microsoft's guidelines for spacing and sizing of controls in dialog boxes state that a combo box should be 14 dialog units high.
I have even tried editing the resource file in notepad and recompiling in Visual Studio without opening the resource editor - but the combo boxes a开发者_如何转开发re still the wrong size!
Any ideas?
The height you provide for the combo box specifies the size of the combo box when it is opened. The height of the edit control portion is based on the font. (Or based on your item size if you are owner-draw.)
in my case, i have handled WM_WINDOWPOSCHANGING message and altered cy member in WINDOWPOS structure, it works, may help.
Now let's suppose you want to change size of the drop down area (the list that appears when you press the button). Remember that the combo box used to be just an edit box and a list glued together in old times. So we will need to change the total width/height somehow.
One way is to edit the width/height in the RC file directly.
The astonishing thing with the VS dialog editor is that it will by default create a default "drop" area of almost zero pixels. You won't see the list at all!
In the dialog editor, hover your mouse cursor above the drop down button until the mouse cursor becomes the north-south type. Then click and the real bounds will show and you can modify the area.
Example:
You can get the combo components HWNDs and sizes with WTL::CComboBox::GetComboBoxInfo(), for instance in your OnInitDialog():
COMBOBOXINFO cbi = {sizeof COMBOBOXINFO};
CComboBox(GetDlgItem(ID_MYCOMBO)).GetComboBoxInfo(&cbi);
CRect rComboEdit = cbi.rcItem;
// adjust rComboEdit to your needs
CEdit(cbi.hwndItem).MoveWindow(rComboEdit);
精彩评论