Solved

Programmatically set the dropdown height of combo box

Posted on 2001-06-18
7
439 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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 …
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.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

920 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

15 Experts available now in Live!

Get 1:1 Help Now