Udostępnij za pośrednictwem


CHeaderCtrl::GetOverflowRect

Gets the bounding rectangle of the overflow button of the current header control.

BOOL GetOverflowRect(
     LPRECT lpRect
) const;

Parameters

Parameter

Description

[out] lpRect

Pointer to a RECT structure that receives the bounding rectangle information.

Return Value

true if this function is successful; otherwise, false.

Remarks

If the header control contains more items than can be simultaneously displayed, the control can display an overflow button that scrolls to items that are not visible. The header control must have the HDS_OVERFLOW and HDF_SPLITBUTTON styles to display the overflow button. The bounding rectangle encloses the overflow button and exists only when the overflow button is displayed. For more information, see Header Control Styles.

This method sends the HDM_GETOVERFLOWRECT 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 the variable, m_headerCtrl, that is used to access the current header control. This variable is used in the next example.

    CHeaderCtrl m_headerCtrl;
    CSplitButton m_splitButton;

The following code example demonstrates the GetOverflowRect method. In an earlier section of the code, we created a header control with five columns. However, you can drag a column separator so that the column is not visible. If some columns are not visible, the header control draws an overflow button. The following code example draws a 3D rectangle around the location of the overflow button.

void CNVC_MFC_CHeaderCtrl_s4Dlg::OnXGetoverflowrect()
{
    if (controlCreated == FALSE) {
        MessageBox(_T("Header control has not been created yet."));
        return;
    }
    CRect rect;
    // Get the overflow rectangle.
    BOOL bRetVal = m_headerCtrl.GetOverflowRect(&rect);
    // Get the device context.
    CDC* pDC = m_headerCtrl.GetDC();
    // Draw around the overflow rect a rectangle that has red 
    // left and top sides, and green right and bottom sides.
    pDC->Draw3dRect(rect, RGB(255, 0, 0), RGB(0, 255, 0));
}

See Also

Reference

CHeaderCtrl Class

Hierarchy Chart

HDM_GETOVERFLOWRECT

RECT

Other Resources

CHeaderCtrl Members