HeaderPane
Main
Hide
Share Link
Print

Pictures

Registers the size and sets the default item pictures used for all items.

C

BOOL WINAPI SftBox_SetPictures(HWND hwndCtl, LPCSFT_PICTURE lpPics);

C++

BOOL CSftBox::SetPictures(LPCSFT_PICTURE lpPics);

Parameters

hwndCtl

The window handle of the combo box control.

lpPics

A pointer to an array of three SFT_PICTURE structures to be used as default item pictures. In a fixed height combo box, all item pictures must be the same size, but can be different types. It is possible to mix bitmaps, icons and ImageList images. These three pictures are used as default item pictures for 1) an expandable parent item, 2) an expanded parent item and 3) an item without dependent items. If a SFT_PICTURE structure describes a bitmap handle, the top, left pixel of the bitmap must contain the image's background color. This color will be replaced by the actual window background color when the bitmap is displayed. This parameter may be NULL to stop displaying item pictures.

Returns

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

Comments

The SetPictures function registers the size and sets the default item pictures used for all items.

There are no default item pictures until SetPictures is used.

SetPictures can be used to define default item pictures using bitmaps, icons or ImageList images.

In a fixed height combo box, all item pictures used for all items must be the same size. New pictures can be registered at any time, but all item pictures in use must be replaced by pictures of the new size.

In a variable height combo box (see SFTBOXSTYLE_VARIABLE), item pictures can be of varying sizes. The item picture size registered is the largest width and the largest height of the three pictures. Item pictures defined using SetItemPicture must be of equal or smaller size.

Individual item pictures can be set using SetItemPicture, but will not be shown unless the item picture size has been registered. The height of all items is adjusted automatically to allow the complete picture to be displayed. The default pictures can be changed even after items have been added to the combo box control. Items without individual item picture will immediately use the new default pictures.

The item pictures are shown in the dropdown portion and, for the selected item, in the static portion of the combo box. GetShowBitmaps can be used to determine if item pictures are shown.

The application retains ownership of any resources used to define the pictures and cannot free these resources until the combo box control no longer uses these (usually until the combo box control is destroyed or the pictures are changed).

Examples

C View entire sample code

#define SFTDARKMODE_IMPLEMENTATION
#include "SftDarkMode.h"                /* Dark mode support */

#include "resource.h"                   // application resources

HINSTANCE g_hInst;                      // App Instance Handle

/**********************************************************************/
/*                              Pictures                              */
/**********************************************************************/

// This sample uses the small icons Windows provides. Bitmaps, image lists,
// GDI+ images and color samples can be used in the same way, see the
// Sft_SetPictureXxx functions in SftPicture2.h.

enum {

C++ View entire sample code

        m_ahIcons[i] = NULL;
        if (SUCCEEDED(SHGetStockIconInfo(aIconIds[i], SHGSI_ICON | SHGSI_SMALLICON, &sii)))
            m_ahIcons[i] = sii.hIcon;
    }
}

CMainDlg::~CMainDlg()
{
    // Pictures are owned by the application and can be deleted
    // once the controls using them have been destroyed.
    for (int i = 0 ; i < ICON_COUNT ; ++i) {
        if (m_ahIcons[i])
            DestroyIcon(m_ahIcons[i]);
    }
}

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


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