Hide

SftTree/DLL 7.5 - Tree Control

Display
Print

ItemPicture

Defines an item's item picture.

C

BOOL WINAPI SftTree_GetItemPicture(HWND hwndCtl, int index, LPSFT_PICTURE lpPicture);
BOOL WINAPI SftTree_SetItemPicture(HWND hwndCtl, int index, LPCSFT_PICTURE lpPicture);
BOOL WINAPI SftTreeSplit_GetItemPicture(HWND hwndCtl, int index, LPSFT_PICTURE lpPicture);
BOOL WINAPI SftTreeSplit_SetItemPicture(HWND hwndCtl, int index, LPCSFT_PICTURE lpPicture);

C++

BOOL CSftTree::GetItemPicture(int index, LPSFT_PICTURE lpPicture) const;
BOOL CSftTree::SetItemPicture(int index, LPCSFT_PICTURE lpPicture);
BOOL CSftTreeSplit::GetItemPicture(int index, LPSFT_PICTURE lpPicture) const;
BOOL CSftTreeSplit::SetItemPicture(int index, LPCSFT_PICTURE lpPicture);

Parameters

hwndCtl

The window handle of the tree control.

index

The zero-based index of the item for which the item picture is to be retrieved or set.

lpPicture

A pointer to a SFT_PICTURE structure to use 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. This parameter may be NULL to remove an item's item picture.

Returns

Get/SetItemPicture returns TRUE if the function was successful, otherwise FALSE is returned.

Comments

The GetItemPicture and SetItemPicture functions define an item's item picture.

Get/SetItemPicture can be used to define an item picture using a bitmap, icon or ImageList image. Get/SetItemBitmap can be used to define an item picture using a bitmap handle only.

In a fixed height tree control, 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 tree control, item pictures can be of varying sizes. The largest picture size must be registered using SetPictures. Item pictures defined using SetItemBitmap must be of equal or smaller size.

If an item doesn't have an item picture, 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.

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

In a tree control 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 SFTTREE_ITEM structure is used instead.

Examples

C

#define IDC_TREE                100     /* Tree control ID */
#define TIMERID                 10      /* Timer ID */

HINSTANCE g_hInst;                      // App Instance Handle
HWND g_hwndTree;                        /* Tree control */

// Miscellaneous bitmaps
SFT_PICTURE m_aThreeItemPictures[3];    /* Three default item pictures, see SetPictures in online help */
//SFT_PICTURE m_OtherItemPicture;       /* Another item picture, see SetItemPicture in online help */
HICON m_hIconSmall;                     /* a small icon */
HBITMAP m_hBitmapSmall;                 /* a small bitmap */
HBITMAP m_hBitmapLarge;                 /* a large bitmap */
HIMAGELIST m_hImgList;                  /* Imagelist control */

HBITMAP m_BitmapClosed = NULL;          // Folder images (if GDI+ is not available)
HBITMAP m_BitmapOpen = NULL;

C++

void CSampleView::UpdatePictures(int index, SFT_PICTURE* pPic, int align)
{
    int w, h;

    SetCellPicture(index, pPic, align);

    Sft_GetPictureSize(pPic, &w, &h);
    if (w <= PIC_SIZEX || h <= PIC_SIZEY)  { // don't use images that are too large
        m_Tree.SetItemPicture(index, pPic);
        m_Tree.SetItemLabelPicture(index, pPic);
        SetRowPicture(index, pPic);
    }
}

void CSampleView::CopyPictureFromCurrentItem()
{

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