Partager via


CListBox::GetItemRect

Retrieves the dimensions of the rectangle that bounds a list-box item as it is currently displayed in the list-box window.

int GetItemRect(
   int nIndex,
   LPRECT lpRect 
) const;

Parameters

  • nIndex
    Specifies the zero-based index of the item.

  • lpRect
    Specifies a long pointer to a RECT structure that receives the list-box client coordinates of the item.

Return Value

LB_ERR if an error occurs.

Example

// Dump all of the items bounds.
CString str;
RECT r;
for (int i = 0; i < m_myListBox.GetCount(); i++)
{
   m_myListBox.GetItemRect(i, &r);

   str.Format(_T("item %d: left = %d, top = %d, right = %d, ")
      _T("bottom = %d\r\n"),
      i,
      r.left,
      r.top,
      r.right,
      r.bottom);
   AFXDUMP(str);
}

Requirements

Header: afxwin.h

See Also

Reference

CListBox Class

Hierarchy Chart

LB_GETITEMRECT

Other Resources

CListBox Members