Share via


CListCtrl::GetGroupRect

Retrieves the bounding rectangle for a specified group in the current list-view control.

BOOL GetGroupRect(
     int iGroupId, 
     LPRECT lpRect, 
     int iCoords = LVGGR_GROUP
) const;

Parameters

Parameter

Description

[in] iGroupId

Specifies a group.

[in, out] lpRect

Pointer to a RECT structure. If this method is successful, the structure receives the rectangle coordinates of the group that is specified by iGroupId.

[in] iCoords

Specifies the rectangle coordinates to retrieve. Use one of these values:

  • LVGGR_GROUP - (Default) Coordinates of the entire expanded group.

  • LVGGR_HEADER - Coordinates of only the header (collapsed group).

  • LVGGR_SUBSETLINK - Coordinates of only the subset link (markup subset).

Return Value

true if this method is successful; otherwise, false.

Remarks

The caller is responsible for allocating the RECT structure pointed to by the pRect parameter.

This method sends the LVM_GETGROUPRECT message, which is described in the Windows SDK.

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. In an earlier section of 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 group whose index is 0, if such a group exists.

// GetGroupRect 

    // Get the graphics rectangle that surrounds group 0.
    CRect rect;
    BOOL bRet = m_listCtrl.GetGroupRect( 0, &rect, LVGGR_GROUP); 
    // Draw a blue rectangle around group 0. 
    if (bRet == TRUE) {
        m_listCtrl.GetDC()->Draw3dRect( &rect, RGB(0, 0, 255), RGB(0, 0, 255));
    }
    else {
        AfxMessageBox(_T("No group information was retrieved."), MB_ICONINFORMATION);
    }

See Also

Reference

CListCtrl Class

Hierarchy Chart

LVM_GETGROUPRECT

RECT

Other Resources

CListCtrl Members