TreeCtrl LPARAM 이용하기
1. TreeCtrl 구성
TV_INSERTSTRUCT tvstruct;
HTREEITEM item, item2;
tvstruct.hParent = NULL;
tvstruct.hInsertAfter = TVI_LAST;
tvstruct.item.mask = TVIF_TEXT | TVIF_PARAM;
tvstruct.item.pszText = "코스피";
tvstruct.item.lParam = (LPARAM)"KOSPI";
item = m_treeCtrl.InsertItem(&tvstruct);
tvstruct.item.pszText = "코스닥";
tvstruct.item.lParam = (LPARAM) "KOSDAQ";
item2 = m_treeCtrl.InsertItem(&tvstruct);
tvstruct.hParent = item;
tvstruct.item.pszText = "동양약품";
tvstruct.item.lParam = (LPARAM)"000020";
m_treeCtrl.InsertItem(&tvstruct);
2. LPARAM 얻기
NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
// TODO: Add your control notification handler code here
char* str = (char*)m_treeCtrl.GetItemData(pNMTreeView->itemNew.hItem);
또는
char* str1 = (char*)pNMTreeView->itemNew.lParam;
SetItemData(), GetItemData() 사용하면 형변환이 필요없다고 언급되어 있음.