Solved

Programmatically set the dropdown height of combo box

Posted on 2001-06-18
7
444 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 Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
iSeries FTP Exit Program 8 147
deburging in oracle form 12 105
Whole sheet autoscrub still needed 19 52
bigDiff challenge 17 126
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.

821 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