Combo box will not drop down in VS2005 MFC Dll

Posted on 2011-10-13
Last Modified: 2012-05-12
I have an MFC Dll created in VS2005.  In this dll, I have a dialog (CDialog) that has a few controls, including a combo box.

In the resource editor, I've dragged (expanded out) the list portion of the combo box to about an inch tall, so it can display several combo items when selected.  I then set the style to "Drop List".  At run time, I populate the combo box with several strings.  However, when I click the combo box's arrow, it doesn't spawn the drop list.  Instead, I only see the currently selected combo item.  I have already tested at runtime to ensure there are several combo items in the combo box, using myComboBox.GetCount().  There are 4 combo items as I expect there to be.  I've put a debugger stop in the message handler that handles the ON_CBN_SELCHANGE message.  However, this message handler NEVER GETS CALLED. I'm sure this is a big clue as to what's going on.  I've also (in an attempt to debug) handle the set focus message for the combo box. This message handler DOES get called.  So I know that the debugger is recognizing my combo box control variable myComboBox.

Not sure if this is issue is directly related to the MFC dll, or whether it might also exist in a 2005 MFC application.

By the way, the combo box is on a basic dialog (derived from CDialog).  Nothing fancy going on there.

Any help would be greatly appreciated.
Question by:cjm20
    LVL 16

    Expert Comment

    In the dialog editor, check the size of the drop-down.

    If you click in the text portion of the combo, you will get an outline of the control.  But if you click on the down arrow, you will get an outline of the size of the control when the drop-down list pops up.
    LVL 32

    Accepted Solution

    to add to above comment:

    it is somewhat unexpected what HooKooDooKu explained about design of a combobox with the resource editor where you have two different rectangles for size depending on the position in the control you do the mouse click. but that "feature" already came with the very first "apstudio" of the vc compiler in 1993.

    if you look in the .rc file you have only coordinates for one rectangle for the combobox. that works cause when you click to the edit part of the combobox you only can change the width and when clicking to the down arrow you only can change the height. that means you can't design a different edit height when using the resource editor (though that is possible programmatically for example by calling MoveWindow).



    Author Closing Comment

    Thanks Sara!!!!.  I've always shy-ed away from manually editing the .rc file, but in this case, it was necessary for me to modify the combo box height in the .rc file, because simply expanding the combo box in the resource editor was NOT making the combo box reflect this height at runtime.  I checked the .rc file, and despite my efforts to increase the height of the combo box, the .rc file kept listing the combo height as "13".

     Normally, to create the list height for the combo box, I set the combo box "Style" property to "Simple", and then " manually "drag" the combo box's "list portion" down about an inch, so that at runtime, about 1 inch worth of combo items can be seen.  Then, after dragging the height to about an inch, I then change the "Style" property of the combo box again to "Drop List".  This technique had worked 100% of the time in the past, in numerous applications, in VC6, VS2005, and VS2010.  However, this technique did NOT work in VS2005 with an MFC Dll.

     Thus, I modified the height of the combo box manually in the .rc file, changing it from 13 to 63.  Problem solved.
    LVL 32

    Expert Comment

    good job :)

    you might delete the *.aps file (same name as project and rc file) and try again to do the change within the resource editor. the .aps file is a binary equivalent of the .rc file (will be created again after you deleted it) and unfortunately it overrules some times changes you made in rc. it is well possible that the problems you had, came from .aps file.


    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
    Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
    The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
    The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

    754 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

    21 Experts available now in Live!

    Get 1:1 Help Now