现在想要获得某个节点的坐标,然后在该节点创建一个菜单 ,不知道如何获得该节点的坐标
可以用GetItemRect函数,
代码如下:
HTREEITEM hmyItem = m_TreeCtrl.GetSelectedItem();
// Dump the bounds of hmyItem.
if (hmyItem != NULL)
{
RECT r;
m_TreeCtrl.GetItemRect(hmyItem, &r, FALSE);
TRACE(TEXT("left = %d, top = %d, right = %d, bottom = %d\r\n"),
r.left,
r.top,
r.right,
r.bottom);
}
r的坐标值是相对于树状控件的左上角。
您可以详细参考下面这个链接:
https://msdn.microsoft.com/en-us/library/c11b5ed4(v=vs.110).aspx
提醒一点:
在使用此函数前,应该手动或者使用EnsureVisible函数使 该节点可见