Solved

Programmatically set the dropdown height of combo box

Posted on 2001-06-18
7
447 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 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
iSeries DB2 Query 2 100
Smart Camera scanning and reading information 3 126
Window placement 17 99
Excel file not created as expected 7 105
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

742 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