CComboBox display list

Posted on 2006-05-10
Last Modified: 2013-11-20
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,
Question by:cophi
    LVL 48

    Accepted Solution

    Open dialog editor, click on combobox arrow, and resize combobox. This defines size of dropdown list.
    LVL 22

    Expert Comment

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

    LVL 22

    Expert Comment

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


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Suggested Solutions

    Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
    Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
    This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    794 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now