Remarks: using icons and the 'ILC_MASK' style for the image list ensures that you don't have to bother about the look of the image when the item is selected or not selected. Simply use a transparent background for the icon and use the same image index for nImage and nSelectedImage when you add the item.

You can use other approaches if you aim to obtain different effects. See MSDN for details.

If you want an item to show different images when it is expanded and collapsed, handle the 'TVN_ITEMEXPANDED' message and use 'SetItemImage(hItem, nImage, nImage)' to set the items image according to its state: