Hide

SftTree/DLL 7.5 - Tree Control

Display
Print

HeaderRect

Returns the dimensions of the column header area.

C

void WINAPI SftTree_GetHeaderRect(HWND hwndCtl,
        int iCol,
        LPRECT lpRect);
void WINAPI SftTreeSplit_GetHeaderRect(HWND hwndCtl,
        int iCol,
        LPRECT lpRect);

C++

void CSftTree::GetHeaderRect(int iCol, LPRECT lpRect) const;
void CSftTreeSplit::GetHeaderRect(int iCol, LPRECT lpRect) const;

Parameters

hwndCtl

The window handle of the tree control.

iCol

The zero-based column number whose location is to be retrieved. If -1 is specified, the location of the entire column header area is returned.

lpRect

A pointer to a RECT structure where the location of the requested column header is returned.

Comments

The GetHeaderRect function returns the dimensions of the column header area.

GetHeaderRect does not handle merged column headers. If cell or column merging is used, GetDisplayHeaderRect should be used instead.

An empty rectangle is returned if an invalid column number is specified or column headers are not shown (see SetShowHeader).

The coordinates returned in lpRect are coordinates relative to the tree control's client area (in pixels).

The row/column header area can be retrieved using GetRowColHeaderRect.

Examples

C

    if (x < 0 && y < 0)             // Shift+F10 or VK_APPS pressed (not used in this sample)
        return;

    pt.x = x; pt.y = y;
    MapWindowPoints(NULL, hwndTree, &pt, 1);

    // check if header right-clicked - we don't show the context menu there
    SftTree_GetHeaderRect(hwndTree, -1, &rect);
    if (PtInRect(&rect, pt))
        return;

    // check if an item cell right-clicked
    index = SftTree_CalcIndexFromPointEx(hwndTree, &pt);
    if (index >= 0 && index < SftTree_GetCount(hwndTree)) {
        // on an item
        ShowItemMenu(hwndParent, hwndTree, index, x, y);

C++

    if (pt.x < 0 && pt.y < 0)             // Shift+F10 or VK_APPS pressed (not used in this sample)
        return;

    ptTree = pt;
    ScreenToClient(&ptTree);

    // check if header right-clicked - we don't show the popup there
    m_Tree.GetHeaderRect(-1, &rect);
    if (PtInRect(&rect, ptTree))
        return;

    // check if an item cell right-clicked
    index = m_Tree.CalcIndexFromPointEx(&ptTree);
    if (index >= 0 && index < m_Tree.GetCount()) {
        // on an item
        ShowItemMenu(index, pt);

See Also C/C++ API | Categories | Notifications