To get context menu pop- up on exact tree-list ctrl text Add this inside
OnContextMenu function
// If you want this to be done from right click OnNMRCLlickTree1 event you can calulate point as
//::GetCursorPos(&point);
UINT uFlags;
CRect rc;
CPoint clickpoint = point;
CPoint mypoint = point;
m_str_tree.ScreenToClient(&mypoint);
HWND htemp;
:: GetDlgItem(htemp,IDC_TREE);
HTREEITEM htItem = m_str_tree.HitTest(mypoint, &uFlags);
CString TreeText2 = m_str_tree.GetItemText(htItem);
m_str_tree.GetItemRect(htItem, &rc, TRUE);
if (mypoint.x > rc.right || mypoint.x < rc.left)
{
return;
}
or
{
return;
}
CMenu mnuPopupSubmit;
mnuPopupSubmit.LoadMenu(IDR_MENU1);
CMenu *mnuPopupMenu = mnuPopupSubmit.GetSubMenu(0);
ASSERT(mnuPopupMenu);
mnuPopupMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, clickpoint.x, clickpoint.y, this);
<pre>
void CPathFinderDlg::OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu)
{
CDialogEx::OnInitMenuPopup(pPopupMenu, nIndex, bSysMenu);
HICON hIcon = AfxGetApp()->LoadIcon(IDB_IMAGE);
pPopupMenu->
SetMenuItemBitmaps(ID__File, MF_BYCOMMAND, &m_bitmapvar_16, NULL);
}