Hide

SftTree/DLL 7.5 - Tree Control

Display
Print

Buttons

Registers the size and sets the images used for expand/collapse buttons.

C

BOOL WINAPI SftTree_SetButtons(HWND hwndCtl, HBITMAP hButtons);
BOOL WINAPI SftTreeSplit_SetButtons(HWND hwndCtl, HBITMAP hButtons);

C++

BOOL CSftTree::SetButtons(int val = 0);
BOOL CSftTree::SetButtons(HBITMAP Bitmap);
BOOL CSftTree::SetButtons(const CBitmap& Bitmap);
BOOL CSftTreeSplit::SetButtons(int val = 0);
BOOL CSftTreeSplit::SetButtons(HBITMAP Bitmap);
BOOL CSftTreeSplit::SetButtons(const CBitmap& Bitmap);

Parameters

hwndCtl

The window handle of the tree control.

hButtons, Bitmap

A predefined value or a bitmap containing four equal-sized images of an expand/collapse button in the following 4 states:

  • up, expandable item. The default is a 12 x 11 button with a '+' image.
  • up, expanded item. The default is a 12 x 11 button with a '-' image.
  • down, expandable item. The default is a 12 x 11 button with a '+' image.
  • down, expanded item. The default is a 12 x 11 button with a '-' image.

The buttons are arranged horizontally in the bitmap, so the height of the bitmap is the height of one button and the width of the bitmap is four times the width of one button. The top, left pixel of each button image must contain the background color. This color will be replaced by the actual window background color when the bitmap is displayed. This parameter may be NULL or omitted to restore the default, built-in bitmap.

The following predefined button styles are available:

SFTTREE_BUTTON_STANDARDSmall gray button image with + and - symbols.
SFTTREE_BUTTON_STDWIDEWide gray button image with + and - symbols.
SFTTREE_BUTTON_LARGELarge gray button image with up and down symbols.
SFTTREE_BUTTON_SIMPLEWhite box with + and - symbols, similar to Windows Explorer.
SFTTREE_BUTTON_MODERNThe button style is not based on a bitmap. It is determined by the Windows release and is rendered by Windows. Note: On Windows XP and above, the button will always be rendered using the "Windows Classic" style, as standard buttons supported by most themes are not suitable for use as expand/collapse buttons due to their small size.
SFTTREE_BUTTON_THEMEDButton image as used on Windows XP. This style is not limited to Windows XP as it is based on a bitmap. No actual Windows themes are used.
SFTTREE_BUTTON_AUTOMATICDepending on the Windows version and available features, the control selects the appropriate button style. On Windows XP (and above) with themes, SFTTREE_BUTTON_THEMED is selected. On all other Windows versions or if themes are not available, SFTTREE_BUTTON_MODERN is selected.
SFTTREE_BUTTON_AUTOMATIC2Depending on the Windows version and available features, the control selects the appropriate button style. On Windows XP (and above) with themes, the button image is rendered using the currently selected Windows theme. On all other Windows versions or if themes are not available, SFTTREE_BUTTON_SIMPLE is selected. A Windows Vista themed button looks like a Windows XP button. For a look similar to Windows Explorer on Windows Vista, select SFTTREE_BUTTON_AUTOMATIC3 instead.
SFTTREE_BUTTON_AUTOMATIC3Depending on the Windows version and available features, the control selects the appropriate button style. On Windows XP with themes, the button image is rendered using the currently selected Windows theme. On Windows Vista (and above) with themes, a look similar to Windows Explorer is used (based on GDI+ images). On all other Windows versions or if themes are not available, SFTTREE_BUTTON_SIMPLE is selected.
SFTTREE_BUTTON_USERDEFThe expand/collapse button images are defined using the members ButtonExpanded, ButtonCollapsed of the SFTTREE_CONTROL structure using Get/SetControlInfo.

val

The only allowable value is 0, which is used to restore the default, built-in bitmap.

Returns

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

Comments

Registers the size and sets the images used for expand/collapse buttons.

All items use the same expand/collapse bitmap. Expand/collapse buttons are only shown if enabled using SetShowButtons and/or SetShowButton0. The application retains ownership of the bitmap and cannot delete the bitmap until the tree control no longer uses the bitmap (usually until the tree control is destroyed or the bitmap is changed using SetButtons).

Sample bitmaps for expand/collapse buttons are provided in the directory \Program Files\Softelvdm\SftTree DLL 7.5\Images. On Windows 64-bit versions, the root folder is \Program Files (x86).

Expand/collapse buttons for individual items can be suppressed using the SetItemExpandCollapseButton function.

When using SFTTREE_BUTTON_AUTOMATIC3 to adapt the button style based on the current operating system used, the application must be marked as supporting specific operating systems (see https://msdn.microsoft.com/en-us/library/windows/desktop/dn481241). Users can further override the determined operating system using the application's compatibility settings.

Examples

C

            // CellInfo.Cell.flag = SFTTREE_BMP_RIGHT;
            // SftTree_SetCellInfo(g_hwndTree, &CellInfo);
        }

        SftTree_SetTreeLineStyle(g_hwndTree, SFTTREE_TREELINE_AUTOMATIC0);/* Dotted tree lines (incl. level 0) */
        SftTree_SetShowButtons(g_hwndTree, TRUE);/* Expand/collapse buttons (level 1..n) */
        SftTree_SetShowButton0(g_hwndTree, TRUE);/* Show expand/collapse buttons (level 0) */
        if (SftTree_GetGDIPlusAvailable(g_hwndTree))
            SftTree_SetButtons(g_hwndTree, SFTTREE_BUTTON_USERDEF);/* User-defined buttons */
        else
            SftTree_SetButtons(g_hwndTree, SFTTREE_BUTTON_AUTOMATIC3);/* Automatic button style 3 */
        SftTree_SetShowGrid(g_hwndTree, TRUE);/* Show grid */
        SftTree_SetGridStyle(g_hwndTree, SFTTREE_GRID_BOTH_DOT);/* Dotted grid lines */
        SftTree_SetShowTruncated(g_hwndTree, TRUE);/* Show ... if truncated */
        SftTree_SetSelectionStyle(g_hwndTree, SFTTREE_SELECTION_ALL | SFTTREE_SELECTION_OUTLINE);/* Select entire item using outline */
        SftTree_SetSelectionArea(g_hwndTree, SFTTREE_SELECTIONAREA_ALLCELLS);/* Selection changes by clicking on an item's cells */

C++

        // Sft_SetPictureBitmap(&CellInfo.Cell.CellPicture1, m_CellBitmap);
        // CellInfo.Cell.flag = SFTTREE_BMP_RIGHT;
        // m_Tree.SetCellInfo(&CellInfo);
    }
    m_Tree.SetTreeLineStyle(SFTTREE_TREELINE_AUTOMATIC0);/* Dotted tree lines (incl. level 0) */
    m_Tree.SetShowButtons(TRUE);         /* Expand/collapse buttons (level 1..n) */
    m_Tree.SetShowButton0(TRUE);         /* Show expand/collapse buttons (level 0) */
    if (m_Tree.GetGDIPlusAvailable())
        m_Tree.SetButtons(SFTTREE_BUTTON_USERDEF);/* User-defined buttons */
    else
        m_Tree.SetButtons(SFTTREE_BUTTON_AUTOMATIC3);/* Automatic button style 3 */
    m_Tree.SetShowGrid(TRUE);            /* Show grid */
    m_Tree.SetGridStyle(SFTTREE_GRID_BOTH_DOT);/* Dotted grid lines */
    m_Tree.SetShowTruncated(TRUE);       /* Show ... if truncated */
    m_Tree.SetSelectionStyle(SFTTREE_SELECTION_ALL | SFTTREE_SELECTION_OUTLINE);/* Select entire item using outline */
    m_Tree.SetSelectionArea(SFTTREE_SELECTIONAREA_ALLCELLS);/* Selection changes by clicking on an item's cells */

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