Hide

SftTree/DLL 7.5 - Tree Control

Display
Print

Pictures

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

C

BOOL WINAPI SftTree_SetPictures(HWND hwndCtl, LPCSFT_PICTURE lpPics);
BOOL WINAPI SftTreeSplit_SetPictures(HWND hwndCtl, LPCSFT_PICTURE lpPics);

C++

BOOL CSftTree::SetPictures(int val = 0);
BOOL CSftTree::SetPictures(LPCSFT_PICTURE lpPics);
BOOL CSftTreeSplit::SetPictures(int val = 0);
BOOL CSftTreeSplit::SetPictures(LPCSFT_PICTURE lpPics);

Parameters

hwndCtl

The window handle of the tree control.

lpPics

A pointer to three SFT_PICTURE structures to be used as default item pictures. In a fixed height tree control, 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) a leaf item. If the SFT_PICTURE structure describes a bitmap handle, the top, left pixel of each 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 or omitted to stop displaying item bitmaps.

val

The only allowable value is 0, which is used to stop displaying item pictures.

Returns

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

Comments

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

There are no default item pictures.

Get/SetPictures can be used to define default item pictures using a bitmaps, icons or ImageList images. Get/SetBitmaps can be used to define default item pictures using bitmap handles only.

In a fixed height tree control, 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 tree control, item pictures can be of varying sizes. The largest picture size must be registered using SetBitmaps. 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 default pictures have been registered using SetPictures. The height of all tree 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 tree control. Items without individual item bitmap will immediately use the new default bitmaps.

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).

An individual item's item picture can be defined using SetItemPicture.

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++

    } else {
        m_BitmapClosed.LoadBitmap(MAKEINTRESOURCE(IDB_EXPANDABLE));
        m_BitmapOpen.LoadBitmap(MAKEINTRESOURCE(IDB_EXPANDED));
        m_BitmapLeaf.LoadBitmap(MAKEINTRESOURCE(IDB_LEAF));
        Sft_SetPictureBitmap(&aPic[0], m_BitmapClosed);/* Expandable picture */
        Sft_SetPictureBitmap(&aPic[1], m_BitmapOpen);/* Expanded picture */
        Sft_SetPictureBitmap(&aPic[2], m_BitmapLeaf);/* Leaf picture */
    }
    m_Tree.SetPictures(aPic);        /* Use item pictures */
    /* Override individual item bitmaps using: */
    // m_OtherItemPicture.LoadBitmap(IDB_your_bitmap);/* Item bitmap */
    // Sft_SetPictureBitmap(&Pic, m_OtherItemPicture);/* Assign bitmap */
    // m_Tree.SetItemPicture(index, &Pic);/* Set an item picture */
    m_Tree.SetItemPictureAlign(TRUE);    /* Align item bitmaps */
    /* Register the cell picture size.  All cell pictures used */
    /* must be the same size.  Only one picture needs to be    */

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