65,206
社区成员
发帖
与我相关
我的任务
分享
// get the mouse position
const MSG* pMessage;
pMessage = GetCurrentMessage();
ASSERT(pMessage);
CPoint point;
point = pMessage->pt; // get the point from the message
ScreenToClient(&point); // convert the point's coords to be relative
// to this control
// see if the point falls on a tree item
UINT flags = 0;
HTREEITEM hItem = HitTest(point, &flags);
if (hItem && (flags & TVHT_ONITEM))
{
// it did fall on an item
}
重载CTreectrl 的
TVN_ITEMEXPANDING
example
void CFTPTREEDlg::OnItemexpandingFtptree(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_TREEVIEW* pnmtv = (NM_TREEVIEW*)pNMHDR;
// TODO: Add your control notification handler code here
HTREEITEM hItem = pnmtv->itemNew.hItem;
if (pnmtv->action == TVE_EXPAND)
{
TVITEM item;
item.hItem = hItem;
m_FtpTreeCtl.GetItem(&item);
item.iImage = 2;
m_FtpTreeCtl.SetItem(&item);
}
else
{
TVITEM item;
item.hItem = hItem;
m_FtpTreeCtl.GetItem(&item);
item.iImage = 1;
m_FtpTreeCtl.SetItem(&item);
}
*pResult = 0;
}