Hamish Morrison
Hamish Morrison

Reputation: 11

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 are still the wrong size!

Any ideas?

Upvotes: 1

Views: 2573

Answers (4)

E. van Putten
E. van Putten

Reputation: 673

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:

Dialog editor trick

Upvotes: 1

Batuhan Ozkaya
Batuhan Ozkaya

Reputation: 11

in my case, i have handled WM_WINDOWPOSCHANGING message and altered cy member in WINDOWPOS structure, it works, may help.

Upvotes: 1

Raymond Chen
Raymond Chen

Reputation: 45173

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.)

Upvotes: 2

Alain Rist
Alain Rist

Reputation: 837

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);

Upvotes: 0

Related Questions