Hide

SftTree/DLL 7.5 - Tree Control

Display
Print

AdjustCellEditRect

Returns a cell's location in client area coordinates of the left or right pane of a split tree control.

C

BOOL WINAPI SftTree_AdjustCellEditRect(HWND hwndCtl,
        int index,
        int realCol,
        LPRECT lpRect);
BOOL WINAPI SftTreeSplit_AdjustCellEditRect(HWND hwndCtl,
        int index,
        int realCol,
        LPRECT lpRect);

C++

BOOL CSftTree::AdjustCellEditRect(int index,
        int realCol,
        LPRECT lpRect) const;
BOOL CSftTreeSplit::AdjustCellEditRect(int index,
        int realCol,
        LPRECT lpRect) const;

Parameters

hwndCtl

The window handle of the tree control.

index

The zero-based index of the cell for which the position is to be adjusted.

realCol

The zero-based column number of the cell for which the position is to be adjusted.

lpRect

The coordinates of the cell relative to the client area of the tree control, usually retrieved using GetDisplayCellRect. On return, these coordinates are adjusted to be relative to the client area of the left or right pane of a split tree control. In a tree control without splitter bar, this function has no effect.

Returns

The return value is TRUE if the function was successful, otherwise FALSE.

Comments

The AdjustCellEditRect function returns a cell's location in client area coordinates of the left or right pane of a split tree control.

This function is used for cell editing. Controls such as edit controls or combo boxes, which are created by the application for cell editing, are created with the tree control as the parent window. When a split tree control is used, the control must be attached to the left or right pane, not the tree control. AdjustCellEditRect is used to calculate the coordinates for the control relative to the left or right pane, one of which is the parent window of the control.

GetCellEditWindow is used to retrieve the window handle of the pane, which will be the parent of the control used for cell editing.

AdjustCellEditRect has no effect in a tree control without splitter bar. But it is recommended to use AdjustCellEditRect in case the application is later converted to use a split tree control.

Examples

C

    SftTree_SetCaretIndex(g_hwndTree, index); // <<<< added:  selection follows item being edited

    /* Change selection style to not shown anything */
    SftTree_SetNoFocusStyle(g_hwndTree, SFTTREE_NOFOCUS_NOTHING);

    /* Copy the text found in the tree control */
    SftTree_GetTextCol(g_hwndTree, m_editIndex, m_editCol, szBuffer);

    SftTree_AdjustCellEditRect(g_hwndTree, m_editIndex, m_editCol, &rect);
    EditParent = SftTree_GetCellEditWindow(g_hwndTree, m_editIndex, m_editCol);

    // based on font height, get best height for the control used for cell editing
    hFont = (HFONT) SendMessage(g_hwndTree, WM_GETFONT, 0, 0);
    {
        int diff;
        TEXTMETRIC tm;

C++

    /* Change selection style to not shown anything */
    m_Tree.SetNoFocusStyle(SFTTREE_NOFOCUS_NOTHING);

    /* Copy the text found in the tree control */
    CString str;
    m_Tree.GetText(m_editIndex, m_editCol, str);

    m_Tree.AdjustCellEditRect(m_editIndex, m_editCol, &rect);
    CWnd* pEditParent = m_Tree.GetCellEditWindow(m_editIndex, m_editCol);

    // based on font height, get best height for the control used for cell editing
    CFont* pFont = m_Tree.GetFont();

    int diff;
    TEXTMETRIC tm;
    CDC* pDC = GetDC();    

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