TreeView 控件使用例子

1. 介绍两个个结构:

 

a. 项目结构

typedef struct tagTVITEMW { UINT mask; HTREEITEM hItem; UINT state; UINT stateMask; LPWSTR pszText; int cchTextMax; int iImage; int iSelectedImage; int cChildren; LPARAM lParam; } TVITEMW, *LPTVITEMW; #define TVITEM TVITEMW #define TV_ITEM TVITEM

b. 插入结构

typedef struct tagTVINSERTSTRUCTW { HTREEITEM hParent; HTREEITEM hInsertAfter; #if (_WIN32_IE >= 0x0400) union { TVITEMEXW itemex; TV_ITEMW item; } DUMMYUNIONNAME; #else TV_ITEMW item; #endif } TVINSERTSTRUCTW, *LPTVINSERTSTRUCTW; #define TVINSERTSTRUCT TVINSERTSTRUCTW #define TV_INSERTSTRUCT TVINSERTSTRUCT

 

2. 使用例子

TV_ITEM item; item.mask = TVIF_TEXT | TVIF_PARAM; item.cchTextMax = 2; item.pszText = L"C: "; TV_INSERTSTRUCT insert; insert.hParent = TVI_ROOT; insert.hInsertAfter = TVI_LAST; insert.item = item; HTREEITEM hRoot1 = m_cTreeCtl.InsertItem(&insert); item.pszText = L"windows"; item.cchTextMax = 7; insert.hParent = hRoot1; insert.item = item; m_cTreeCtl.InsertItem(&insert);

 

 

(具体说明后期会加入)

 

你可能感兴趣的:(MFC,通用控件)