Returns an item's height (in pixels).
C
int WINAPI SftBox_GetItemHeight(HWND hwndCtl, LONG index);
C++
int CSftBox::GetItemHeight(LONG index) const;
hwndCtl
The window handle of the combo box control.
index
The zero-based index of the item for which the item height is to be retrieved. Specify -1 to retrieve the height required to display the selected item in the static portion.
The return value is the height (in pixels) of the specified item in the dropdown portion. If index is -1, the height required to display the selected item in the static portion is returned. -1 is returned if the specified item doesn't exist. If the combo box control contains no items and index is 0, the height an item would use is returned.
The GetItemHeight function returns an item's height (in pixels).
In a fixed height combo box, all items have the same height. The best height for items is automatically calculated based on the fonts, pictures and other attributes used. If multi-line text is desired, SetItemLines should be used to set the expected (maximum) number of text lines per item. This ensures that multiple lines of text will fit within the vertical space allocated to each item.
In a variable height combo box (see SFTBOXSTYLE_VARIABLE), the height of each item is determined individually.
The SetItemHeightMinMax function can be used to define an item's minimum and maximum height (in pixels).
SftBox_LimitText(m_hwndSizes, 3);
}
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);
}
m_Sizes.LimitText(3);
}
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);
}
See Also C/C++ API | Categories | Notifications