VC MFC 鼠标右键菜单

2024-12-02 10:03:54
推荐回答(1个)
回答1:

//在Tree内:
void DIALOG1::OnRclickTree1(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
LPPOINT lpoint=new tagPOINT;
::GetCursorPos(lpoint); //获得鼠标
CMenu menu,*pSubMenu;
menu.LoadMenu(IDR_MENU2); //添加菜单资源
pSubMenu=menu.GetSubMenu(0); //设置菜单弹出项目起始位置
pSubMenu->TrackPopupMenu(TPM_LEFTALIGN,lpoint->x,lpoint->y,this); //获得鼠标位置
*pResult = 0;
}