WIN32 SDK TreeView控件有关问题请问

WIN32 SDK TreeView控件问题请教!
本帖最后由 c_cwh1 于 2013-12-17 16:15:25 编辑
我的本意是在树控件中选择某一项后获取该项文本,如果我使用6.0版本以前的Comctl32就没问题,但是,如果使用6.0或以后的就不能正常获取,显示为空,请教下坛里的高手是不是有什么需要特别注意的地方,谢谢!

// 把下面这句注释掉就可以,否则就不能取到文本
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.1' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")

我是在TVN_SELCHANGED中处理的
LPNMTREEVIEW lpTvControl = (LPNMTREEVIEW)lParam;
LPTVITEMEX pTviSel = (TVITEMEX*)lpTvControl->itemNew.hItem;
::MessageBoxW(hWnd, pTviSel->pszText, tv.pszText, MB_OK);


------解决方案--------------------
6.0 有很多控件的实现方法有所不同,且 MSDN 也有说:
引用
The itemOld and itemNew members of the NMTREEVIEW structure are TVITEM structures that contain information about the previously selected item and the newly selected item. Only the mask, hItem, state, and lParam members of these structures are valid.

所以最好采用获取文字的方式。
TCHAR szText[256];
TVITEMEX tviex;
tviex.mask = TVIF_HANDLE 
------解决方案--------------------
 TVIF_TEXT;
tviex.hItem = lpTvControl->itemNew.hItem;
tviex.pszText = szText;
tviex.cchTextMax = _countof(szText);
TreeView_GetItem(hWnd, &tviex);