ON_NOTIFY(NM_RCLICK, IDC_LIST_ShowMsg, &CDlg::OnNMRClickListShowmsg)
//list右键菜单
void CDlg::OnNMRClickListShowmsg(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);
// TODO: 在此添加控件通知处理程序代码
LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
int index = pNMLV->iItem;
if (index == -1)
return;
HMENU hMenu = ::CreatePopupMenu();
AppendMenu(hMenu, MF_STRING, 10001, _T("定位到文件所在"));
AppendMenu(hMenu, MF_STRING, 10002, _T("删除所选文件"));
AppendMenu(hMenu, MF_STRING, 10003, _T("取消"));
CPoint pt;
GetCursorPos(&pt); //获得当前鼠标位置
UINT Cmd = (UINT)::TrackPopupMenu(hMenu, TPM_LEFTALIGN | TPM_RETURNCMD, pt.x, pt.y, 0, m_hWnd, NULL);//弹出菜单
switch (Cmd)//响应点击的菜单
{
case 10001:
break;
case 10002:
break;
case 10003:
break;
}
*pResult = 0;
}