如何实现树控件单击事件
展开全部
试试下面这个方法:void CTestView::OnClickTree1(NMHDR* pNMHDR, LRESULT* pResult)
{
CTreeCtrl* pCtrl = (CTreeCtrl*) GetDlgItem(IDC_TREE1);
CString m_sText ="";
CPoint point;
GetCursorPos(&point);
pCtrl->ScreenToClient(&point);
UINT flag = TVHT_ONITEM;
HTREEITEM hItem = pCtrl->HitTest(point,&flag);
if (hItem != NULL)
{
pCtrl->SelectItem(hItem);
m_sText = pCtrl->GetItemText(hItem);
if(m_sText=="左边树的响应事件的名称")
{
实现你的功能......
}
*pResult = 0;
}
{
CTreeCtrl* pCtrl = (CTreeCtrl*) GetDlgItem(IDC_TREE1);
CString m_sText ="";
CPoint point;
GetCursorPos(&point);
pCtrl->ScreenToClient(&point);
UINT flag = TVHT_ONITEM;
HTREEITEM hItem = pCtrl->HitTest(point,&flag);
if (hItem != NULL)
{
pCtrl->SelectItem(hItem);
m_sText = pCtrl->GetItemText(hItem);
if(m_sText=="左边树的响应事件的名称")
{
实现你的功能......
}
*pResult = 0;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询