Retrieves the bounding rectangle for all or part of a subitem in the current list-view control.
BOOL GetItemIndexRect( PLVITEMINDEX pItemIndex, int iColumn, int rectType, LPRECT pRect ) const;
Pointer to an LVITEMINDEX structure for the parent item of the subitem.
The caller is responsible for allocating and setting the members of the LVITEMINDEX structure. This parameter cannot be NULL.
Zero-based index of a column in the control.
Portion of the list-view subitem for which the bounding rectangle is retrieved. Specify one of the following values:
LVIR_BOUNDS - Returns the bounding rectangle of the entire subitem, including the icon and label.
LVIR_ICON - Returns the bounding rectangle of the icon or small icon of the subitem.
LVIR_LABEL - Returns the bounding rectangle of the subitem text.
Pointer to a RECT structure that receives information about the bounding rectangle of the subitem.
The caller is responsible for allocating the RECT structure. This parameter cannot be NULL.
This control is supported in Windows Vista and later.
Additional requirements for this method are described in Build Requirements for Windows Vista Common Controls.
The following code example defines a variable, m_listCtrl, that is used to access the current list-view control. This variable is used in the next example.
The following code example demonstrates the GetGroupRect method. Prior to entering this code example we created a list-view control that displays two columns titled "ClientID" and "Grade" in a report view. The following code example draws a 3D rectangle around the second subitem in both columns.
// GetItemIndexRect // Get the rectangle that bounds the second item in the first group. LVITEMINDEX lvItemIndex; lvItemIndex.iGroup = 0; lvItemIndex.iItem = 1; CRect rect; BOOL bRet = m_listCtrl.GetItemIndexRect( &lvItemIndex, 0, LVIR_BOUNDS, &rect); // Draw a red rectangle around the item. m_listCtrl.GetDC()->Draw3dRect( &rect, RGB(255, 0, 0), RGB(255, 0, 0) );