Поделиться через


CTreeCtrl::SetItemData

Call this function to set the 32-bit application-specific value associated with the specified item.

BOOL SetItemData(
   HTREEITEM hItem,
   DWORD_PTR dwData 
);

Параметры

  • hItem
    Handle of the item whose data is to be retrieved.

  • dwData
    A 32-bit application-specific value associated with the item specified by hItem.

Возвращаемое значение

Nonzero if successful; otherwise 0.

Пример

CString   str;
HTREEITEM hItem;

// Insert 20 items into the tree control making every item's
// data be the handle of the item.
for (int i = 0; i < 20; i++)
{
   str.Format(TEXT("item %d"), i);
   hItem = m_TreeCtrl.InsertItem(str);

   if (hItem != NULL)
   {
      m_TreeCtrl.SetItemData(hItem, (DWORD_PTR)hItem);
   }
}

Требования

Header: afxcmn.h

См. также

Основные понятия

CTreeCtrl Class

CTreeCtrl Members

Hierarchy Chart

CTreeCtrl::GetItemData