- Notifications
You must be signed in to change notification settings - Fork 961
/
Copy pathccombobox-class_29.cpp
27 lines (23 loc) · 847 Bytes
/
ccombobox-class_29.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// CMyComboBox is my owner-drawn combo box derived from CComboBox. This
// example measures an item and sets the height of the item to twice the
// vertical extent of its text. The combo box control was created with
// the following code:
// pmyComboBox->Create(
// WS_CHILD|WS_VISIBLE|WS_BORDER|WS_HSCROLL|WS_VSCROLL|
// CBS_SORT|CBS_OWNERDRAWVARIABLE,
// myRect, pParentWnd, 1);
//
voidCMyComboBox::MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct)
{
ASSERT(lpMeasureItemStruct->CtlType == ODT_COMBOBOX);
if (lpMeasureItemStruct->itemID != (UINT)-1)
{
LPCTSTR lpszText = (LPCTSTR)lpMeasureItemStruct->itemData;
ASSERT(lpszText != NULL);
CSize sz;
CDC *pDC = GetDC();
sz = pDC->GetTextExtent(lpszText);
ReleaseDC(pDC);
lpMeasureItemStruct->itemHeight = 2 * sz.cy;
}
}