HeaderPane
Main
Hide
Share Link
Print

Buttons

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

C

BOOL WINAPI SftBox_SetButtons(HWND hwndCtl, HBITMAP hButtons);

C++

BOOL CSftBox::SetButtons(HBITMAP hButtons);

Parameters

hwndCtl

The window handle of the combo box control.

hButtons

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 to restore the default, built-in bitmap.

The following predefined button styles are available:

SFTBOX_BUTTON_STANDARDSmall gray button image with + and - symbols.
SFTBOX_BUTTON_STDWIDEWide gray button image with + and - symbols.
SFTBOX_BUTTON_LARGELarge gray button image with up and down symbols.
SFTBOX_BUTTON_SIMPLEWhite box with + and - symbols, similar to Windows Explorer.
SFTBOX_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.
SFTBOX_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.
SFTBOX_BUTTON_AUTOMATICDepending on the Windows version and available features, the control selects the appropriate button style. On Windows XP (and above) with themes, SFTBOX_BUTTON_THEMED is selected. On all other Windows versions or if themes are not available, SFTBOX_BUTTON_MODERN is selected.
SFTBOX_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, SFTBOX_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 SFTBOX_BUTTON_AUTOMATIC3 instead.
SFTBOX_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, SFTBOX_BUTTON_SIMPLE is selected.

Returns

The return value is always TRUE.

Comments

The SetButtons function registers the size and sets the images used for expand/collapse buttons.

All items use the same expand/collapse bitmap, in the dropdown portion and in the static portion of the combo box control. Expand/collapse buttons are only shown if enabled using SetShowButtons and/or SetShowButton0. Selecting SFTBOX_BUTTON_STANDARD (NULL), SFTBOX_BUTTON_SIMPLE, SFTBOX_BUTTON_MODERN, SFTBOX_BUTTON_THEMED, SFTBOX_BUTTON_AUTOMATIC, SFTBOX_BUTTON_AUTOMATIC2 or SFTBOX_BUTTON_AUTOMATIC3 also enables the expand/collapse buttons of items other than level 0, as if SetShowButtons(TRUE) had been called. The application retains ownership of the bitmap and cannot delete the bitmap until the combo box control no longer uses the bitmap (usually until the combo box control is destroyed or the bitmap is changed using SetButtons).

If the dropdown portion of a dropdown or dropdown list combo box is visible, it is hidden when SetButtons is called.

When using SFTBOX_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 View entire sample code

    Sft_SetPictureIcon(&aThreeItemPictures[0], m_ahIcons[ICON_FOLDER]);    /* Expandable picture */
    Sft_SetPictureIcon(&aThreeItemPictures[1], m_ahIcons[ICON_FOLDEROPEN]);/* Expanded picture */
    Sft_SetPictureIcon(&aThreeItemPictures[2], m_ahIcons[ICON_DOCUMENT]);  /* Leaf picture */
    SftBox_SetPictures(hwndBox, aThreeItemPictures);

    SftBox_SetTreeLineStyle(hwndBox, SFTBOX_TREELINE_AUTOMATIC);// Dotted or invisible tree lines, following the Windows theme
    SftBox_SetShowButtons(hwndBox, TRUE);       // Expand/collapse buttons (level 1..n)
    SftBox_SetShowButton0(hwndBox, TRUE);       // Expand/collapse buttons (level 0)
    SftBox_SetButtons(hwndBox, SFTBOX_BUTTON_AUTOMATIC);// Button style follows the Windows theme
    SftBox_SetDroppedHeight(hwndBox, 12);       // Show up to 12 items
    SftBox_SetDarkMode(hwndBox, SFTBOX_DARKMODE_AUTO);

    // The level of an item defines the hierarchy: an item is a
    // dependent of the closest preceding item with a lower level.
    for (i = 0 ; i < FOLDER_COUNT ; ++i) {
        LONG index = SftBox_AddString(hwndBox, m_aFolders[i].lpszText);

C++ View entire sample code

    Sft_SetPictureIcon(&aThreeItemPictures[0], m_ahIcons[ICON_FOLDER]);    /* Expandable picture */
    Sft_SetPictureIcon(&aThreeItemPictures[1], m_ahIcons[ICON_FOLDEROPEN]);/* Expanded picture */
    Sft_SetPictureIcon(&aThreeItemPictures[2], m_ahIcons[ICON_DOCUMENT]);  /* Leaf picture */
    m_Folders.SetPictures(aThreeItemPictures);

    m_Folders.SetTreeLineStyle(SFTBOX_TREELINE_AUTOMATIC);// Dotted or invisible tree lines, following the Windows theme
    m_Folders.SetShowButtons(TRUE);     // Expand/collapse buttons (level 1..n)
    m_Folders.SetShowButton0(TRUE);     // Expand/collapse buttons (level 0)
    m_Folders.SetButtons(SFTBOX_BUTTON_AUTOMATIC);// Button style follows the Windows theme
    m_Folders.SetDroppedHeight(12);     // Show up to 12 items
    m_Folders.SetDarkMode(SFTBOX_DARKMODE_AUTO);

    // The level of an item defines the hierarchy: an item is a
    // dependent of the closest preceding item with a lower level.
    for (i = 0 ; i < count ; ++i) {
        LONG index = m_Folders.AddString(aFolders[i].lpszText);

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


Last Updated 11/21/2026 - (email)
© 2026 Softel vdm, Inc.