views:

532

answers:

2

I'm coding an app in MSVS 2008, which has a ComboBox control which I initialize thru the code as below:

static char*                    OptionString[4] = {"Opt1",
                                                   "Opt2",
                                                   "Opt3",
                                                   "Opt4"};


BOOL CMyAppDlg::OnInitDialog()
{
    CDialog::OnInitDialog();

 // Set the icon for this dialog.  The framework does this automatically
 //  when the application's main window is not a dialog
 SetIcon(m_hIcon, TRUE);   // Set big icon
 SetIcon(m_hIcon, FALSE);  // Set small icon

    // TODO: Add extra initialization here

    m_Option.AddString(OptionString[0]);
    m_Option.AddString(OptionString[1]);
    m_Option.AddString(OptionString[2]);
    m_Option.AddString(OptionString[3]);
    m_Option.SetCurSel(0);

    return TRUE;  // return TRUE  unless you set the focus to a control
}

In the above code, m_Option is the Control variable for the ComboBox Control.

Now, when I build the app and click the down-arrow, the drop-down box shows the first option ONLY(since I've selected that thru my code). But, if i press down-arrow key on keyboard, it cycles thru the options in the order I've inserted, but never does it show more than 1 option in the box. So, In case an user wants to select option3, he has to cycle through options 1 and 2 !! Though once I select any option using the keyboard, the appropriate event handlers are fired, I'm miffed by this behaviour , as is understandable.

I'm listing the properties of the combo-box control as well - only the properties that are true(rest are set to false):

  1. Type - Dropdown
  2. Vertical Scrollbar
  3. Visible Tabstop

This has bugged me for weeks now. Can anyone pls enlighten me ?

+2  A: 

You need to increase the height of the drop down of combo box in designer.

Through the designer by default you can just resize the ComboBox width. If you want to resize the Drop Down List height you need to click on the dropdown arrow on the right, then you'll be able to resize the dropped control height. This seems so easy but if no-one tells you it's anything but intuitive.

Hope you understood my point.

Sunil
How to do that ? Can u at least tell me the property name ?
shan23
Got it....I didnt see u had edited ur first answer, and had marked the other one as the answer in the meanwhile !! Anyway, thanks to both of u...I have also included a link which painstakingly describes this... :)
shan23
+5  A: 

In the dialog layout designer, while designing the dialog, click the "down arrow" on the combobox. You can then drag down on the bottom of the combobox's outline to increase its height.

jwismar
MFC sucks!! This should be a property....how else would some one know !!! Anyways, for ppl (like me) stuck with MFC, here's a good link :http://www.eggheadcafe.com/software/aspnet/29801328/how-to-increase-the-ccomb.aspx
shan23
In fairness, that's not an MFC thing, it's a native-code dialog designer thing - predates MFC. And those common controls predate the idea of "controls" as we think of them, with properties, etc. And also for what it's worth, MFC was a lot better than straight API programming in C!But you're right, if you don't know this idiom for setting the height of a combobox's dropdown, you're not likely ever to find it on your own.
jwismar