Hide

SftTree/DLL 7.5 - Tree Control

Display
Print

ColumnsEx

Defines the number of columns and column attributes.

C

int WINAPI SftTree_GetColumnsEx(HWND hwndCtl, LPSFTTREE_COLUMN_EX* lpColArray);
BOOL WINAPI SftTree_SetColumnsEx(HWND hwndCtl, int count, LPCSFTTREE_COLUMN_EX lpCols);
int WINAPI SftTreeSplit_GetColumnsEx(HWND hwndCtl, LPSFTTREE_COLUMN_EX *lpColArray);
BOOL WINAPI SftTreeSplit_SetColumnsEx(HWND hwndCtl, int count, LPCSFTTREE_COLUMN_EX lpCols);

C++

int GetColumns(int val) const;
int GetColumns(LPSFTTREE_COLUMN_EX FAR * lpCols) const;
BOOL SetColumns(int count, int val);
BOOL SetColumns(int count, LPSFTTREE_COLUMN_EX lpColArray);

Parameters

hwndCtl

The window handle of the tree control.

count

The number of columns to be defined. A SFTTREE_COLUMN_EX entry must be defined for each column. This number may be 0, in which case a single, open-ended last column is defined (the lpCols parameter is ignored).

lpCols

A pointer to SFTTREE_COLUMN_EX structure(s), one for each column to be defined. This pointer may be NULL if count is 0, to define a single column.

lpColArray

A pointer to a pointer to SFTTREE_COLUMN_EX structure(s). This pointer will be set on return to contain a pointer to column structures, each describing one column. This pointer may be NULL, in which case only the number of columns will be returned.

val

The only allowable value is 0 or NULL, which is used to retrieve the number of columns (lpCols == NULL) or to define a single column (lpColArray == NULL).

Returns

GetColumns returns the number of columns currently defined and sets a pointer to SFTTREE_COLUMN_EX structure(s).

SetColumns returns TRUE if the function was successful, FALSE otherwise.

Comments

The GetColumns(Ex) and SetColumns(Ex) functions define the number of columns and column attributes.

The pointer returned in parameter lpColArray points to SFTTREE_COLUMN_EX structures, one for each column defined. The values in these structures may be modified (in-place) and updated using SetColumns.

The number of columns can only be modified if the tree control is empty.

To define the last column as open-ended use SetOpenEnded. An open-ended last column will display the complete text specified for the last (or only) column and never truncate any data. A fixed-width last column is defined with a specified width and any data which doesn't fit is truncated.

Due to the variable number of levels and the resulting hierarchical display, the width of the first column is always treated as a minimum width. The text portion of the first column will always be at least of the specified width, no matter what level the item is on. This can result in the first column being much wider than the defined width. See GetOverheadWidth for additional information.

An application should use RecalcHorizontalExtent or SetHorizontalExtent to recalculate or set the optimal horizontal scrolling extent.

Additional forms of the GetColumns(Ex)/SetColumns(Ex) functions exist, which use a SFTTREE_COLUMN structure, but are only provided for compatibility with earlier versions of SftTree/DLL and are not documented.

Examples

C

    SftTree_GetCellInfo(hwndTree, &CellInfo);

    Sft_GetPictureSize(&CellInfo.Cell.CellPicture1, &w, &h);

    if (w <= PIC_SIZEX || h <= PIC_SIZEY)  { // don't use images that are too large for the header
        // copy it to row/column header and column header
        SftTree_SetRowColHeaderPicture(hwndTree, &CellInfo.Cell.CellPicture1);/* Row/column picture */

        nCols = SftTree_GetColumnsEx(hwndTree, &lpCol);/* Get column attributes */
        Sft_CopyPicture(&lpCol[1].Picture1, &CellInfo.Cell.CellPicture1); // second column
        SftTree_SetColumnsEx(hwndTree, nCols, lpCol);  /* Set new column attributes */
    } else {
        SftTree_SetRowColHeaderPicture(hwndTree, NULL);

        nCols = SftTree_GetColumnsEx(hwndTree, &lpCol);/* Get column attributes */
        Sft_ClearPicture(&lpCol[1].Picture1); // second column

C++

    m_Tree.GetCellInfo(&CellInfo);

    Sft_GetPictureSize(&CellInfo.Cell.CellPicture1, &w, &h);

    if (w <= PIC_SIZEX || h <= PIC_SIZEY)  { // don't use images that are too large for the header
        // copy it to row/column header and column header
        m_Tree.SetRowColHeaderPicture(&CellInfo.Cell.CellPicture1);/* Row/column picture */

        nCols = m_Tree.GetColumns(&lpCol);/* Get column attributes */
        Sft_CopyPicture(&lpCol[1].Picture1, &CellInfo.Cell.CellPicture1); // second column
        m_Tree.SetColumns(nCols, lpCol);  /* Set new column attributes */
    } else {
        m_Tree.SetRowColHeaderPicture(NULL);

        nCols = m_Tree.GetColumns(&lpCol);/* Get column attributes */
        Sft_ClearPicture(&lpCol[1].Picture1); // second column

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