I'm using a CTreeCtrl populated from DB values to display a hiearchy (user--reports---updates)
Populating it is working just fine, I select all users, loop through selecting all reports, looping through selecting all updates.
Within each loop I track the parent and add the items accordingly. For each line item, I am using SetItemData(<HTREEITEM>, ID) - ID being the recordset ID for the line item.
This all works. Currently however, I'm manually finding the level of each item, and simply hard-coding that "level 1 refers to users" .. "level 2 refers to reports" .. and "level 3 refers to updates" - and that works as well. I know that an ID on level 2 is the ID of a record from the reports table, and ID on level 3 refers to a record from the updates table etc.
that seems "inappropraite" though - the hard-wiring of that. I have classes modeling each of those tables (lets call them MyUser, MyReport, MyUpdate) and rather than having to rely on "knowing" what each level refers to, I'd like to somehow have each line item in the tree "know" not only the ID, but the "what" the ID is for.
Does that make sense? Can I define some kind of structure which holds a DWORD ID and some kind of string identifier for the type of class I want to instantiate based on the ID of the selection and somehow stuff that into the SetItemData(..) call ?