CComboBox display list

So I have this combo box that I created on my dialog.  I'm adding lots and lots of strings to it.  When I click on the down arrow, it drops down this tiny list selector with really tiny up and down buttons.  I was hoping when you clicked on the down arrow, it would drop down with like 5 or 6 strings showing, and a nice scrollbar on the side, instead of the extremely small one i got.  How do I fix this??? Thanks,
Who is Participating?
Open dialog editor, click on combobox arrow, and resize combobox. This defines size of dropdown list.
if you are looking to set number of lines in dropdown box of combo then following function will  Set the proper number of lines in a drop-down list combo box.

void set_DropDownSize(CComboBox& box, UINT LinesToDisplay)
    ASSERT(IsWindow(box));      // Window must exist or SetWindowPos won't work

    CRect cbSize;                  // current size of combo box
    int Height;            // new height for drop-down portion of combo box

    Height = box.GetItemHeight(-1);      // start with size of the edit-box portion
    Height += box.GetItemHeight(0) * LinesToDisplay;      // add height of lines of text

    // Note: The use of SM_CYEDGE assumes that we're using Windows '95
    // Now add on the height of the border of the edit box
    Height += GetSystemMetrics(SM_CYEDGE) * 2; // top & bottom edges

    // The height of the border of the drop-down box
    Height += GetSystemMetrics(SM_CYEDGE) * 2; // top & bottom edges

    // now set the size of the window
    box.SetWindowPos(NULL,0, 0,cbSize.right, Height,  SWP_NOMOVE | SWP_NOZORDER );

with above function you may programatically change number of lines in dropdown combobox.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.