我用的是预先设计好的菜单资源0为第一个popup菜单项,也可以使用1,2...就看你需要哪个子菜单了.
void CMyDlg::OnRclickTreeSys(NMHDR* pNMHDR, LRESULT* pResult) 
{
// TODO: Add your control notification handler code here
pNMHDR; CTreeCtrl * thistree;
thistree=&m_Tree_Sys; CMenu menu;
CMenu * popupmenu; DWORD retd;
POINTS points;
CPoint pointstree;
retd=GetMessagePos();
points=MAKEPOINTS(retd);
pointstree.x=points.x;
pointstree.y=points.y;
thistree->ScreenToClient(&pointstree);
thistree->SelectItem(thistree->HitTest(pointstree));
if(NULL==thistree->GetSelectedItem())
{
return;
} menu.LoadMenu(IDR_MENU_POPUPMENU);
popupmenu=menu.GetSubMenu(0);
popupmenu->TrackPopupMenu(TPM_LEFTALIGN|TPM_RIGHTBUTTON,points.x,points.y,this);

*pResult = 1;
}

解决方案 »

  1.   


    zb_china:谢谢你,我试了。
    只需在显示菜单的时候加上TPM_RIGHTBUTTON属性就可以。
    准备容器装分吧!
      

  2.   

     奇怪,我开始也以为是TPM_RIGHTBUTTON属性的问题,但是我试了一下,把自己的一段程序中的TPM_RIGHTBUTTON属性删掉,却没有你所说的问题(结果没发贴子!哎......)。
      

  3.   

    我这的确是TPM_RIGHTBUTTON起了作用,
    是不是因为我是响应TabCtrl右键单击的缘故?