CListCtrl::GetItemIndexRect
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;
Parameters
Parameter |
Description |
---|---|
[in] pItemIndex |
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. |
[in] iColumn |
Zero-based index of a column in the control. |
[in] rectType |
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. |
[out] pRect |
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. |
Return Value
true if this method is successful; otherwise, false.
Remarks
This method sends the LVM_GETITEMINDEXRECT message, which is described in the Windows SDK. For more information, see ListView_GetItemIndexRect Macro.
Requirements
Header: afxcmn.h
This control is supported in Windows Vista and later.
Additional requirements for this method are described in Build Requirements for Windows Vista Common Controls.
Example
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.
public:
// Variable used to access the list control.
CListCtrl m_listCtrl;
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) );
See Also
Reference
ListView_GetItemIndexRect Macro