CTreeCtrl::SetItem

BOOL SetItem( TVITEM* pItem );

BOOL SetItem( HTREEITEM hItem, UINT nMask, LPCTSTR lpszItem, int nImage, int nSelectedImage, UINT nState, UINT nStateMask, LPARAM lParam );

Return Value

Nonzero if successful; otherwise 0.

Parameters

pItem

A pointer to a TVITEM structure that contains the new item attributes, as described in the Platform SDK.

hItem

Handle of the item whose attributes are to be set.

nMask

Integer specifying which attributes to set.

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.

nSelectedImage

Index of the item’s selected image in the tree view control’s image list.

nState

Specifies values for the item’s states.

nStateMask

Specifies which states are to be set.

lParam

 A 32-bit application-specific value associated with the item.

Remarks

Call this function to set the attributes of the specified tree view item.

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

// The pointer to my tree control.
extern CTreeCtrl* pmyTreeCtrl;
// The point to hit test.
extern CPoint myPoint;

// Show the item at the point myPoint in bold.
UINT uFlags;
HTREEITEM hItem = pmyTreeCtrl->HitTest(myPoint, &uFlags);

if ((hItem != NULL) && (TVHT_ONITEM & uFlags))
{
   pmyTreeCtrl->SetItem(hItem, TVIF_STATE, NULL, 0, 0, TVIS_BOLD, 
      TVIS_BOLD, 0);
}

CTreeCtrl OverviewClass MembersHierarchy Chart

See Also   CTreeCtrl::GetItem