Defines the height of the dropdown portion.
C
int WINAPI SftBox_GetDroppedHeight(HWND hwndCtl); int WINAPI SftBox_SetDroppedHeight(HWND hwndCtl, int height);
C++
int CSftBox::GetDroppedHeight() const; int CSftBox::SetDroppedHeight(int height);
hwndCtl
The window handle of the combo box control.
height
The height of the dropdown portion.
| Greater than 0 | The maximum number of items shown in the dropdown portion. If the combo box contains fewer items, the dropdown portion is only as high as needed. |
| Less than 0 | The negated value is the maximum height of the dropdown portion in pixels (e.g., -200 for 200 pixels). The height includes the column headers (if shown). The dropdown portion shows as many complete items as fit into this height. |
| 0 | Not valid. |
GetDroppedHeight returns the current height setting of the dropdown portion (see height above). -1 is returned if the combo box is a simple combo box.
SetDroppedHeight returns 0 if the function was successful. -1 is returned if height is 0 or if the combo box is a simple combo box.
The GetDroppedHeight and SetDroppedHeight functions define the height of the dropdown portion.
By default, the dropdown portion shows up to 6 items.
The height defined does not include the borders and the horizontal scroll bar of the dropdown portion. If a horizontal scroll bar is needed, the dropdown portion is enlarged accordingly.
A height defined in pixels is subject to pixel scaling. If pixel scaling is enabled (see SetPixelScaling), the value is scaled by the DPI setting of the monitor.
The setting is used the next time the dropdown portion is shown. If the dropdown portion does not fit on the monitor, it may be shown above instead of below the combo box (or vice versa, see SetDropDownPosition).
If the user resizes the dropdown portion using the resizer (see SetShowResizer), the height setting is replaced by the resulting height in pixels, excluding the borders and the horizontal scroll bar, so GetDroppedHeight returns a negative value. Passing this value to SetDroppedHeight restores the height the user defined.
The height of the dropdown portion of a simple combo box is determined by the size of the combo box window.
SFTBOX_COLUMN aCols[2];
LONG index;
int i;
InitColumn(&aCols[0], 0, 100, TEXT("Color"));
InitColumn(&aCols[1], 1, 100, TEXT("Description"));
SftBox_SetColumns(hwndBox, 2, aCols);
SftBox_SetShowHeaderDropDown(hwndBox, TRUE);// Column titles in the dropdown only
SftBox_SetDroppedHeight(hwndBox, 12); // Show up to 12 items
SftBox_SetDropDownOptimalWidth(hwndBox, TRUE);// The dropdown is as wide as its columns
SftBox_SetDisableNoScroll(hwndBox, TRUE); // Scroll bars always shown, needed for the sizing box
SftBox_SetShowResizer(hwndBox, TRUE); // The user can resize the dropdown
SftBox_SetDarkMode(hwndBox, SFTBOX_DARKMODE_AUTO);
// Register the size of the cell pictures before adding items.
// All pictures in the cells of a control are the same size.
{
SFTBOX_COLUMN aCols[2];
LONG index;
InitColumn(&aCols[0], 0, 100, _T("Color"));
InitColumn(&aCols[1], 1, 100, _T("Description"));
box.SetColumns(2, aCols);
box.SetShowHeaderDropDown(TRUE); // Column titles in the dropdown only
box.SetDroppedHeight(12); // Show up to 12 items
box.SetDropDownOptimalWidth(TRUE); // The dropdown is as wide as its columns
box.SetDisableNoScroll(TRUE); // Scroll bars always shown, needed for the sizing box
box.SetShowResizer(TRUE); // The user can resize the dropdown
box.SetDarkMode(SFTBOX_DARKMODE_AUTO);
// Register the size of the cell pictures before adding items.
// All pictures in the cells of a control are the same size.See Also C/C++ API | Categories | Notifications