Hide

SftTree/DLL 7.5 - Tree Control

Display
Print

ItemLines

Defines the number of text lines used for item height calculation.

C

int WINAPI SftTree_GetItemLines(HWND hwndCtl);
BOOL WINAPI SftTree_SetItemLines(HWND hwndCtl, int nLines);
int WINAPI SftTreeSplit_GetItemLines(HWND hwndCtl);
BOOL WINAPI SftTreeSplit_SetItemLines(HWND hwndCtl, int nLines);

C++

int CSftTree::GetItemLines() const;
BOOL CSftTree::SetItemLines(int nLines);
int CSftTreeSplit::GetItemLines() const;
BOOL CSftTreeSplit::SetItemLines(int nLines);

Parameters

hwndCtl

The window handle of the tree control.

nLines

The number of text lines used to calculate the expected height of items.

Returns

GetItemLines returns the current number of text lines last defined using SetItemLines.

SetItemLines returns TRUE if the function was successful, otherwise FALSE is returned.

Comments

The GetItemLines and SetItemLines functions define the number of text lines used for item height calculation.

The height of items is determined based on an item's attributes such as registered item picture size, label picture size, fonts used, etc. Using SetItemLines, an application can specify how many lines of cell text an item can display in a cell.

In a fixed height tree control (see SFTTREESTYLE_VARIABLE) all cell text has the same number of text lines. If an application needs multiple text lines to support word wrapping (see SFTTREE_COLUMN_EX, SFTTREE_WRAP) or new line characters in cell text, SetItemLines must be used to specify the number of text lines.

In a variable height tree control, each item's height is determined individually. If an application allows word wrapping (see SFTTREE_COLUMN_EX, SFTTREE_WRAP) or new line characters in cell text, SetItemLines must be used to specify the maximum number of text lines to display in all cells. If cell text exceeds the specified number of lines, "+" is shown at the bottom, right corner of the cell.

A tree control defaults to one line of text for each item.

Examples

C

        if (!g_hwndTree)
            return -1;

        /* Resources, such as bitmaps, should be loaded and must remain    */
        /* valid until the tree control is destroyed or no longer uses     */
        /* these.  For example, use DeleteObject to delete any bitmaps.    */

        SftTree_SetShowHeader(g_hwndTree, TRUE);/* Show column headers */
        SftTree_SetItemLines(g_hwndTree, 5); /* (Maximum) number of text lines */
        /* Register the label picture size.  All label pictures    */
        /* used must be the same size.  Only one picture needs to  */
        /* be registered, even if several are used.                */
        Sft_InitPicture(&Pic);
        Sft_SetPictureSizeOnly(&Pic, PIC_SIZEX, PIC_SIZEY);/* Dimensions only for registration */
        SftTree_SetItemLabelPicture(g_hwndTree, -1, &Pic);/* Register the label picture size */
        /* Set individual label bitmaps using the following sample code: */

C++

        WS_HSCROLL | WS_VSCROLL |        /* Vertical and horizontal scrollbars */
        WS_VISIBLE | WS_CHILD,           /* Visible, child window */
        CRect(0,0,0,0),                  /* Location */
        this,                            /* Parent window */
        IDC_TREE))                       /* Tree control ID */
            return -1;
    
    m_Tree.SetShowHeader(TRUE);          /* Show column headers */
    m_Tree.SetItemLines(5);              /* (Maximum) number of text lines */

    SFT_PICTURE Pic;

    /* Register the label picture size.  All label pictures    */
    /* used must be the same size.  Only one picture needs to  */
    /* be registered, even if several are used.                */
    Sft_InitPicture(&Pic);               /* Initialize */

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