Solved

Programmatically set the dropdown height of combo box

Posted on 2001-06-18
7
436 Views
Last Modified: 2013-11-20
I've got a combobox i am dynamically creating.  I can't set the dropdown height of the combobox in devstudio.

I'm doing a
m_combo.Create(WS_CHILD|WS_VISIBLE|CBS_DROPDOWNLIST, rect, this, ID_TEST);

which works fine, but the dropdown has no height.

Thanks for your help,
Marcus
0
Comment
Question by:marcus78
  • 3
  • 3
7 Comments
 
LVL 49

Accepted Solution

by:
DanRollins earned 50 total points
ID: 6205210
There are two possible problems:

1) If there is no data, the combobox always makes the drop-down list very small.  So be sure to add some data.

2) The MDSN documentation is ambiguous on what goes into <rect>  And you didn't show it in your sample code so there is every reason to assume that you have used incorrect values.  

The value of the rect paramter are top, left, bottom, right (and *not* top, left, width, height as one might assume from the documentation).  So...

  CRect rc;
  rc.left= 10;
  rc.right= 100;
  rc.top= 290;
  rc.bottom= 390;

  cCombo.Create(WS_CHILD|WS_VISIBLE|CBS_DROPDOWNLIST, rc, this, 1234);

  cCombo.InsertString(-1,"aaaaaa");
  cCombo.InsertString(-1,"bbbbbb");
  cCombo.InsertString(-1,"cccccc");
  cCombo.InsertString(-1,"dddddd");
  cCombo.InsertString(-1,"eeeeee");
  cCombo.InsertString(-1,"ffffff");
  cCombo.InsertString(-1,"gggggg");
  cCombo.InsertString(-1,"hhhhhh");
  cCombo.InsertString(-1,"iiiiii");
 
-- Dan
0
 
LVL 9

Expert Comment

by:Pacman
ID: 6205218
I think rect describes the whole rect when the combo is "dropped down" (that means editline plus list).
0
 

Author Comment

by:marcus78
ID: 6207493
Dan,

Thanks again!  That is pretty vague. It seems as though the dimensions of the control should be described in <rect>, then a Function Call would set the drop down height.

Also,  Could you cue me in on the best practices around here? Pacman also hinted at the same solution as you did, but I accepted your because it was much more complete.  I definitely don't want to make anyone mad around here, because this is such a great place for info. Is there a better way to accept an answer in this case, or have I done it correctly?

Thanks,
Marcus
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 49

Expert Comment

by:DanRollins
ID: 6211474
>>dimensions of the control should be described in <rect>, then a Function Call would set the drop down height.

ComboBoxes are a bit strange that way.  The height of the "always visible" part of the control is set automatically and is based upon the height of the indivifdual items in the list.

Think of a ComboBox as a List in which the body of the list is hidden.  Then it makes sense that the <rect> must specify that size.  Also remember that if there are few items in the list, the drop-down will be only large enough to show those items.

One other note:  Many programmers don't have a clue about user interface design so they make the drop-down list very short, forcing the user to scroll to see items at the bottom.  It is better to make the list very high so that more items are visible.  The dropdown can extend beyond the bottom of the parent window -- so use that screen realestate.

=-=--=-=-=-=-=
>> Could you cue me in on the best practices around here?
In this case, there is is really no problem -- my solution was first and it was correct and Pacman's comment came after and was not a major contribution.  You only need to worry about dividing up points when two or more experts contribute significantly to the answer.

Another general EE tip:  It is correct to award an A.  If you feel that a comment does not answer the question, you should post follow up comments asking for clarification.  If you don't get a satisfactory answer, it is better to delete the question than to award a "C" just to close the books.

-- Dan
0
 
LVL 9

Expert Comment

by:Pacman
ID: 6213991
> my solution was first and it was correct and Pacman's
comment came after and was not a major contribution.

DanRollins,

I guess marcus' problem was that he didn't know that the rectangle describes the whole control (including the drop down window). I couldn't read this in your comment so I decided to write it.

regards
Pacman
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 6221086
Hi Pacman,
On rereading my comment, I see that it could easily be construed as a criticism of your comment.  I am sorry.  No insult was intended.

-- Dan
0
 
LVL 9

Expert Comment

by:Pacman
ID: 6223633
no problem.

Pacman
0

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

Suggested Solutions

Title # Comments Views Activity
Expand macro to ask for filename column 8 35
notReplace  challenge 53 102
countEvens challenge 2 58
sum67 challenge 35 89
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

708 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

11 Experts available now in Live!

Get 1:1 Help Now