Aracılığıyla paylaş


CListBox::MeasureItem

Sahip çizim stilinde bir liste kutusu oluşturulurken çerçevesi tarafından çağrıldı.

virtual void MeasureItem(
   LPMEASUREITEMSTRUCT lpMeasureItemStruct 
);

Parametreler

Notlar

Varsayılan olarak, bu üye işlev hiçbir şey yapmaz.Bu üye işlevi geçersiz kılabilir ve doldurmak MEASUREITEMSTRUCT Windows liste kutusunun boyutlarını bilgilendirmek için yapı.Liste kutusu ile oluşturduysanız, LBS_OWNERDRAWVARIABLE stili, framework çağıran Bu üye işlevi liste kutusundaki her öğe için.Aksi takdirde bu üyeye yalnızca bir kez çağrılır.

Kullanma hakkında daha fazla bilgi için LBS_OWNERDRAWFIXED ile oluşturulan bir sahibi tarafından çizilen liste kutusundaki Stil SubclassDlgItem üye işlevi CWnd, tartışmalarına bakın Teknik Not 14.

Bkz: CWnd::OnMeasureItem bir açıklaması için MEASUREITEMSTRUCT yapı**.**

Örnek

// CMyODListBox is my owner-drawn list box derived from CListBox. This 
// example measures an item and sets the height of the item to twice the 
// vertical extent of its text. The list box control was created with the 
// following code:
//   m_myODListBox.Create(
//      WS_CHILD|WS_VISIBLE|WS_BORDER|WS_HSCROLL|WS_VSCROLL|
//      LBS_SORT|LBS_MULTIPLESEL|LBS_OWNERDRAWVARIABLE|LBS_WANTKEYBOARDINPUT,
//      CRect(10,250,200,450), pParentWnd, IDC_MYODLISTBOX);
//
void CMyODListBox::MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct)
{
   ASSERT(lpMeasureItemStruct->CtlType == ODT_LISTBOX);
   LPCTSTR lpszText = (LPCTSTR) lpMeasureItemStruct->itemData;
   ASSERT(lpszText != NULL);
   CSize   sz;
   CDC*    pDC = GetDC();

   sz = pDC->GetTextExtent(lpszText);

   ReleaseDC(pDC);

   lpMeasureItemStruct->itemHeight = 2*sz.cy;
}

Gereksinimler

Başlık: afxwin.h

Ayrıca bkz.

Başvuru

CListBox sınıfı

Hiyerarşi grafik

CListBox::CompareItem

CWnd::OnMeasureItem

CListBox::DrawItem

CListBox::DeleteItem