Defines an item's item picture.
C
BOOL WINAPI SftBox_GetItemPicture(HWND hwndCtl, LONG index, LPSFT_PICTURE lpPicture); BOOL WINAPI SftBox_SetItemPicture(HWND hwndCtl, LONG indexTC, LPCSFT_PICTURE lpPicture);
C++
BOOL CSftBox::GetItemPicture(LONG index, LPSFT_PICTURE lpPicture) const; BOOL CSftBox::SetItemPicture(LONG indexTC, LPCSFT_PICTURE lpPicture);
hwndCtl
The window handle of the combo box control.
index, indexTC
The zero-based index of the item for which the item picture is to be retrieved or set. Using SetItemPicture, this parameter may be -1 to register the item picture size if no item picture size has been registered yet.
lpPicture
A pointer to a SFT_PICTURE structure. GetItemPicture returns the item's item picture in this structure. SetItemPicture uses the picture described by this structure as the item picture for the specified item. If the SFT_PICTURE structure defines 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. If indexTC is -1, the picture is only used to determine the size of item pictures. Using SetItemPicture, this parameter may be NULL to remove an item's item picture.
GetItemPicture and SetItemPicture return TRUE if the function was successful, otherwise FALSE is returned.
The GetItemPicture and SetItemPicture functions define an item's item picture.
GetItemPicture and SetItemPicture can be used to define an item picture using a bitmap, icon or ImageList image. GetItemBitmap and SetItemBitmap can be used to define an item picture using a bitmap handle only.
In a fixed height combo box, all item pictures used for all items must be the same size. New default pictures can be registered at any time using SetPictures, 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 largest picture size must be registered using SetPictures. Item pictures defined using SetItemPicture must be of equal or smaller size.
If an item doesn't have an item picture, the default item picture defined using SetPictures is displayed, based on the item's expand/collapse status. If no default item pictures have been defined, the space normally occupied by the item picture is left blank.
An item may have an associated item picture without the item picture area actually being visible. The item picture area doesn't become visible until the item picture size has been registered using SetPictures, or using SetItemPicture by setting indexTC to -1. The registered item picture size applies to the dropdown portion and the static portion. GetShowBitmaps can be used to determine if the item picture area is visible.
The application retains ownership of any resources used to define the picture 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).
In a combo box using a virtual data source, SetItemPicture can only be used to register the picture size, otherwise an error is returned. The ItemPicture member of the SFTBOX_ITEM structure is used instead.
// 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);
SftBox_SetItemLevel(hwndBox, index, m_aFolders[i].level);
if (m_aFolders[i].icon >= 0) {
SFT_PICTURE Picture;
Sft_InitPicture(&Picture);
Sft_SetPictureIcon(&Picture, m_ahIcons[m_aFolders[i].icon]);
SftBox_SetItemPicture(hwndBox, index, &Picture);// Override the default item picture
}
}
// Collapse the top level items
for (i = 0 ; i < FOLDER_COUNT ; ++i) {
if (m_aFolders[i].level == 0)
SftBox_Collapse(hwndBox, i, TRUE);
// dependent of the closest preceding item with a lower level.
for (i = 0 ; i < count ; ++i) {
LONG index = m_Folders.AddString(aFolders[i].lpszText);
m_Folders.SetItemLevel(index, aFolders[i].level);
if (aFolders[i].icon >= 0) {
SFT_PICTURE Picture;
Sft_InitPicture(&Picture);
Sft_SetPictureIcon(&Picture, m_ahIcons[aFolders[i].icon]);
m_Folders.SetItemPicture(index, &Picture);// Override the default item picture
}
}
// Collapse the top level items
for (i = 0 ; i < count ; ++i) {
if (aFolders[i].level == 0)
m_Folders.Collapse(i, TRUE);See Also C/C++ API | Categories | Notifications