大家看看!我这样判断鼠标是否电击到树控件上为何不对?代码为。。。
void CTestDlg::OnContextMenu(CWnd* pWnd, CPoint point)
{
// TODO: Add your message handler code here
HTREEITEM hItem = NULL;
UINT uFlags;
hItem = m_tree.HitTest(point,&uFlags);
//判断鼠标是否点到了TREE的ITEM上面
if ((hItem == NULL) || ((TVHT_ONITEM & uFlags) == 0))
{
MessageBox("not tree");
}
else
{
GetCursorPos(&point);
CPoint mouse = point;
CMenu menu;
menu.LoadMenu(IDR_MENU1);
CMenu* pSubMenu = NULL;
pSubMenu = menu.GetSubMenu(0);
//::TrackPopupMenu(pSubMenu->m_hMenu, TPM_LEFTALIGN , mouse.x, mouse.y, 0,m_hWnd, NULL);
pSubMenu->TrackPopupMenu(TPM_RIGHTBUTTON, mouse.x, mouse.y, this );
pSubMenu -> DestroyMenu();
}
}