0在stdafx.h中进行准备工作
#define _UNIT_ONE 0
#define _UNIT_TWO 1
#define _UNIT_THREE 2
#define _UNIT_FORE 3
typedef struct tag_tree
{
unsigned long nType;
char t_name[20];
int t_id;
}TREEDATA,*LPTREEDATA;
1 在OnInitDialog初始化函数
HTREEITEM hItem = m_tree.InsertItem("目录", NULL, NULL, TVI_ROOT);
HTREEITEM hItem1 =m_tree.InsertItem("镜头",NULL, NULL,hItem);
if(hItem1)
{
LPTREEDATA lpTd=new TREEDATA;
lpTd->nType=_UNIT_ONE;
m_tree.SetItemData(hItem1,(DWORD)lpTd);
}
HTREEITEM hItem2 =m_tree.InsertItem("场景",NULL, NULL,hItem);
if(hItem2)
{
LPTREEDATA lpTd=new TREEDATA;
lpTd->nType=_UNIT_TWO;
m_tree.SetItemData(hItem2,(DWORD)lpTd);
}
HTREEITEM hItem3 =m_tree.InsertItem("电视强",NULL, NULL,hItem);
if(hItem3)
{
LPTREEDATA lpTd=new TREEDATA;
lpTd->nType=_UNIT_THREE;
m_tree.SetItemData(hItem3,(DWORD)lpTd);
}
HTREEITEM hItem4 =m_tree.InsertItem("视频",NULL, NULL,hItem);
if(hItem4)
{
LPTREEDATA lpTd=new TREEDATA;
lpTd->nType=_UNIT_FORE;
m_tree.SetItemData(hItem4,(DWORD)lpTd);
}
2 在OnContextMenu(CWnd* pWnd, CPoint point) 该函数中进行处理
void CEmnuWIDNSSDlg::OnContextMenu(CWnd* pWnd, CPoint point)
{