Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Programmatically set the dropdown height of combo box

Posted on 2001-06-18
7
Medium Priority
?
461 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 49

Accepted Solution

by:
DanRollins earned 200 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

636 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