HeaderPane
Main
Hide
Share Link
Print

ItemHeightMinMax

Defines an item's minimum and maximum height (in pixels).

C

void WINAPI SftBox_GetItemHeightMinMax(HWND hwndCtl, int itemIndex, int* pMin, int* pMax);
BOOL WINAPI SftBox_SetItemHeightMinMax(HWND hwndCtl, int itemIndex, int minHeight, int maxHeight);

C++

void CSftBox::GetItemHeightMinMax(int itemIndex, int* pMin, int* pMax) const;
BOOL CSftBox::SetItemHeightMinMax(int itemIndex, int minHeight, int maxHeight);

Parameters

hwndCtl

The window handle of the combo box control.

itemIndex

In a fixed height combo box, itemIndex must be -1 and defines the minimum and maximum height for all items.

In a variable height combo box (see SFTBOXSTYLE_VARIABLE), itemIndex defines the zero-based index of the item for which the minimum and maximum height is to be retrieved or set.

pMin

A pointer to a variable which returns the currently defined minimum height. If no minimum height has been defined, 0 is returned. This parameter may be NULL if the value is not needed.

pMax

A pointer to a variable which returns the currently defined maximum height. If no maximum height has been defined, 0 is returned. This parameter may be NULL if the value is not needed.

minHeight

Defines the item's minimum height. Specify 0 to allow the combo box to determine the optimal height.

maxHeight

Defines the item's maximum height. Specify 0 to allow the combo box to determine the optimal height.

Returns

SetItemHeightMinMax returns TRUE if the function was successful, otherwise FALSE is returned. The function fails if itemIndex is not valid, if minHeight or maxHeight is negative or if minHeight is greater than maxHeight (when both are defined).

GetItemHeightMinMax has no return value. If itemIndex is not valid, 0 is returned in pMin and pMax.

Comments

The GetItemHeightMinMax and SetItemHeightMinMax functions define an item's minimum and maximum height (in pixels).

Normally, SftBox/DLL determines the best item height for all items by analyzing their attributes. It may be desirable to override this height for certain items or all items. SetItemHeightMinMax can be used to force a defined minimum and maximum height. minHeight and maxHeight can be set to the same value, in which case the defined item(s) will have the specified height.

In a fixed height combo box, the minimum and maximum height applies to all items in the dropdown portion and to the selected item shown in the static portion. The new item height is applied and the combo box is redrawn immediately.

The heights are subject to pixel scaling (see SetPixelScaling).

In a variable height combo box using a virtual data source, SetItemHeightMinMax cannot be used. The minHeight and maxHeight members of the SFTBOX_ITEM structure are used instead.

Examples

C View entire sample code

static void EqualizeHeights(void)
{
    // The height of a combo box follows the height of its items. The font
    // names have a picture and the sizes an edit portion, so use the
    // largest item height as minimum height in all three.
    int height = SftBox_GetItemHeight(m_hwndFonts, -1);
    height = max(height, SftBox_GetItemHeight(m_hwndStyle, -1));
    height = max(height, SftBox_GetItemHeight(m_hwndSizes, -1));
    SftBox_SetItemHeightMinMax(m_hwndFonts, -1, height, 0);
    SftBox_SetItemHeightMinMax(m_hwndStyle, -1, height, 0);
    SftBox_SetItemHeightMinMax(m_hwndSizes, -1, height, 0);
}

/**********************************************************************/
/*                           Dialog Proc                              */
/**********************************************************************/

C++ View entire sample code

void CMainDlg::EqualizeHeights()
{
    // The height of a combo box follows the height of its items. The font
    // names have a picture and the sizes an edit portion, so use the
    // largest item height as minimum height in all three.
    int height = m_Fonts.GetItemHeight(-1);
    height = max(height, m_Style.GetItemHeight(-1));
    height = max(height, m_Sizes.GetItemHeight(-1));
    m_Fonts.SetItemHeightMinMax(-1, height, 0);
    m_Style.SetItemHeightMinMax(-1, height, 0);
    m_Sizes.SetItemHeightMinMax(-1, height, 0);
}

BOOL CMainDlg::OnInitDialog()
{
    CDialog::OnInitDialog();

See Also C/C++ API | Categories | Notifications


Last Updated 11/21/2026 - (email)
© 2026 Softel vdm, Inc.