Share via


CHeaderCtrl::GetItemDropDownRect

Gets the bounding rectangle of the drop-down button for a header item in the current header control.

BOOL GetItemDropDownRect(
     int iItem, 
     LPRECT lpRect
) const;

Parameters

Parameter

Description

[in] iItem

Zero-based index of a header item whose style is HDF_SPLITBUTTON. For more information, see the fmt member of the HDITEM structure.

[out] lpRect

Pointer to a RECT structure to receive the bounding rectangle information.

Return Value

true if this function is successful; otherwise, false.

Remarks

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

Requirements

Header: afxcmn.h

This method 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 GetItemDropDownRect method. In an earlier section of the code, we created a header control with five columns. The following code example draws a 3D rectangle around the location on the first column that is reserved for the header drop-down button.

void CNVC_MFC_CHeaderCtrl_s4Dlg::OnXGetitemdropdownrect()
{
    if (controlCreated == FALSE) {
        MessageBox(_T("Header control has not been created yet."));
        return;
    }

// Get the dropdown rect for the first column.
    CRect rect;
    BOOL bRetVal = m_headerCtrl.GetItemDropDownRect(0, &rect);
    if (bRetVal == TRUE) {
    // Draw around the dropdown rect a rectangle that has red  
    // left and top sides, and blue right and bottom sides.
        CDC* pDC = m_headerCtrl.GetDC();
        pDC->Draw3dRect(rect, RGB(255, 0, 0), RGB(0, 0, 255));
    }
}

See Also

Reference

CHeaderCtrl Class

Hierarchy Chart

HDM_GETITEMDROPDOWNRECT

RECT

HDITEM