CTreeCtrl::SetItem
Call this function to set the attributes of the specified tree view item.
BOOL SetItem(
TVITEM* pItem
);
BOOL SetItem(
HTREEITEM hItem,
UINT nMask,
LPCTSTR lpszItem,
int nImage,
int nSelectedImage,
UINT nState,
UINT nStateMask,
LPARAM lParam
);
Parameters
pItem
A pointer to a TVITEM structure that contains the new item attributes, as described in the Windows SDK.hItem
Handle of the item whose attributes are to be set. See the hItem member of the TVITEM structure in the Windows SDK.nMask
Integer specifying which attributes to set. See the mask member of the TVITEM structure.lpszItem
Address of a string containing the item's text.nImage
Index of the item's image in the tree view control's image list. See the iImage member of the TVITEM structure.nSelectedImage
Index of the item's selected image in the tree view control's image list. See the iSelectedImage member of the TVITEM structure.nState
Specifies values for the item's states. See the State member of the TVITEM structure.nStateMask
Specifies which states are to be set. See the stateMask member of the TVITEM structure.lParam
A 32-bit application-specific value associated with the item.
Return Value
Nonzero if successful; otherwise 0.
Remarks
In the TVITEM structure, the hItem member identifies the item, and the mask member specifies which attributes to set.
If the mask member or the nMask parameter specifies the TVIF_TEXT value, the pszText member or the lpszItem is the address of a null-terminated string and the cchTextMax member is ignored. If mask (or nMask) specifies the TVIF_STATE value, the stateMask member or the nStateMask parameter specifies which item states to change and the state member or nState parameter contains the values for those states.
Example
// Show the item at the point myPoint in bold.
UINT uFlags;
HTREEITEM hItem = m_TreeCtrl.HitTest(myPoint, &uFlags);
if ((hItem != NULL) && (TVHT_ONITEM & uFlags))
{
m_TreeCtrl.SetItem(hItem, TVIF_STATE, NULL, 0, 0, TVIS_BOLD,
TVIS_BOLD, 0);
}
Requirements
Header: afxcmn.h