Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Combo Boxes!

105 views
Skip to first unread message

Sanford H. Selznick

unread,
Dec 25, 1996, 3:00:00 AM12/25/96
to

How do I set the height of a pop down drop list of a combo box? I see
CB_SETDROPPEDWIDTH, but no "CB_SETDROPPEDHEIGHT". The closest relative I
can find is CB_SETITEMHEIGHT, and I don't think it is what I am looking
for.

The combo box is in a modeless dialog box, and has a vertical scrollbar,
and no integral height. It is of type "Drop List" and is set to "No" owner
draw. I am unable to make it any taller in the MS developer studio.

Thanks!
Sanford

Doug Stevens

unread,
Dec 26, 1996, 3:00:00 AM12/26/96
to Sanford H. Selznick

Sanford H. Selznick wrote:
> The combo box is in a modeless dialog box, and has a vertical scrollbar,
> and no integral height. It is of type "Drop List" and is set to "No" owner
> draw. I am unable to make it any taller in the MS developer studio.

In the studio, do the following:

Set the type to a regular list box.
Set the height to whatever you want the drop-down height of the
combo box to be.
Set the type back to a combo box.

Brad Wilson

unread,
Dec 27, 1996, 3:00:00 AM12/27/96
to

> How do I set the height of a pop down drop list of a combo box?

The height of the control is the height of the drop down.

--
Brad Wilson Custom software development & solutions
cru...@pobox.com Internet and intranet consulting services
The Brads' Consulting Windows NT/Windows 95 software development
http://www.thebrads.com Web site planning, development and maintenance
Content (C) 1996 Brad Wilson; no reproduction without authorization


Katy Mulvey

unread,
Dec 27, 1996, 3:00:00 AM12/27/96
to

Sanford H. Selznick <san...@cs.arizona.edu> wrote in article
<sanford-ya0236800...@news.cs.arizona.edu>...

> How do I set the height of a pop down drop list of a combo box? I see
> CB_SETDROPPEDWIDTH, but no "CB_SETDROPPEDHEIGHT". The closest relative I
> can find is CB_SETITEMHEIGHT, and I don't think it is what I am looking
> for.
>
> The combo box is in a modeless dialog box, and has a vertical scrollbar,
> and no integral height. It is of type "Drop List" and is set to "No"
owner
> draw. I am unable to make it any taller in the MS developer studio.

Use SetWindowPos. Remember to include the height of the associated
edit box, too. So, something like:

void set_DropDownSize(CComboBox& box, UINT LinesToShow)
// Notes:
// 1) use SM_CYBORDER for Win3.x or NT
// 2) This won't work for owner-draw variable height combo boxes
// 3) This won't work for a subclassed combo with a horizontal scroll bar
// 4) Call this function after creating the combo box and after a
// WM_SETTINGCHANGE message.
{
ASSERT(IsWindow(box)); // Window must exist or SetWindowPos won't work

CRect cbSize; // current size of combo box
int Height; // new height for drop-down portion of combo box

box.GetClientRect(cbSize);
Height = box.GetItemHeight(-1); // start with size of the edit-box
portion
Height += box.GetItemHeight(0) * LinesToShow; // add height of lines of
text

// Note: The use of SM_CYEDGE assumes that we're using Windows '95
// Now add on the height of the border of the edit box
Height += GetSystemMetrics(SM_CYEDGE) * 2; // top & bottom edges

// The height of the border of the drop-down box
Height += GetSystemMetrics(SM_CYEDGE) * 2; // top & bottom edges

// now set the size of the window
box.SetWindowPos(NULL, // not relative to any other windows
0, 0, // TopLeft corner doesn't change
cbSize.right, Height, // existing width, new height
SWP_NOMOVE | SWP_NOZORDER // don't move box or change z-ordering.
);
}

To change the size in Developer Studio, click on the drop-down arrow.
Notice the extremely subtle change (the highlighted grab handles move
from the left/right to top/bottom) and resize the combo.

--
Katy Mulvey k...@ormec.com
Software Development Engineer
ORMEC Systems http://www.ormec.com


scs0

unread,
Dec 10, 2004, 4:43:50 PM12/10/04
to
I know Microsoft left good design principles at the door when
developing the Windows API, but this functionality can't possibly be
this complicated. I know this is an ancient thread, but does anyone
know the real way to specify the height of the listbox of a combo box?

James Brown

unread,
Dec 10, 2004, 6:52:01 PM12/10/04
to
Use MoveWindow / SetWindowPos, using the
combobox window handle - the height parameter should
be how tall you want the drop-list to be.

--
James
---
www.catch22.net
Free win32 software, sourcecode and tutorials
-----
Please de-spam my email address before replying.
"scs0" <sc...@vol.com> wrote in message
news:1102715030.5...@z14g2000cwz.googlegroups.com...

Tim Robinson

unread,
Dec 10, 2004, 6:52:57 PM12/10/04
to

I had to go to Google Groups to find out what you're talking about
(http://groups-beta.google.com/group/comp.os.ms-windows.programmer.win32/browse_thread/thread/d117157bd104400b?safe=images&as_umsgid=1102715030.5...@z14g2000cwz.googlegroups.com&lr=&hl=en),
but the method explained in the original thread is the real way: when
creating the combo box, the height you give you CreateWindow determines
the height of the list box.

--
Tim Robinson (MVP, Windows SDK)
http://mobius.sourceforge.net/

0 new messages