TreeList 鼠标右键选中节点问题 50分

c2413 2005-10-11 03:53:49
请教各位

point = (CPoint) GetMessagePos();

ScreenToClient(&point);

UINT uFlags;
HTREEITEM htItem;

htItem = m_tree.HitTest( point, &uFlags );

if( hItem == NULL )
{
return;
}

我想得到右键时候的树节点上的ITEM
可是有时候可以有时候不可以
htItem = m_tree.HitTest( point, &uFlags );
有时候返回为空

大家帮帮忙,
...全文
220 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
c2413 2005-10-11
  • 打赏
  • 举报
回复
谢谢了,搞定了,用星星的从原来的CTreeCtrl继承了一个,就可以了
zxyjyzxyjy 2005-10-11
  • 打赏
  • 举报
回复
我是这样做的,在响应鼠标右击时。
void CCustTreeCtrl::OnRButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
POINT TmpPoint = point;
ClientToScreen (&TmpPoint);
UINT uFlags;
HTREEITEM hItem = HitTest(point, &uFlags);
if ((hItem != NULL) && (TVHT_ONITEM & uFlags))
{

}
}
快乐鹦鹉 2005-10-11
  • 打赏
  • 举报
回复
The GetMessagePos function retrieves the cursor position for the last message retrieved by the GetMessage function.

To determine the current position of the cursor, use the GetCursorPos function.
快乐鹦鹉 2005-10-11
  • 打赏
  • 举报
回复
用GetCursorPos试试

15,979

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧