Swapnil Gupta
Swapnil Gupta

Reputation: 8941

how to create new Property for MFC(VC++) treeview Control?

How to create new Property for MFC(VC++) treeview Control?

Upvotes: 1

Views: 1364

Answers (1)

casablanca
casablanca

Reputation: 70721

SetItemData is the standard way of associating additional data with a tree item. If you're already using it to store the tooltip, that's okay, you can create a structure which holds all the data you want:

struct Data {
  LPCTSTR tooltip;
  // add other data members here
};

Then set a structure pointer as the item data:

Data *data = new Data;
// initialize data members here
tree.SetItemData(hItem, static_cast<DWORD_PTR>(data));

And when you want to retrieve the data:

Data *data = static_cast<Data *>(tree.GetItemData(hItem));

Also remember to delete the allocated memory when you are removing the tree items.

Upvotes: 1

Related Questions