码迷,mamicode.com
首页 > 其他好文 > 详细

ListControl响应右键,弹出菜单

时间:2014-09-14 19:14:27      阅读:204      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   os   ar   div   sp   log   on   

 1 void CTHREADDLG::OnRclickList(NMHDR* pNMHDR, LRESULT* pResult) 
 2 {
 3     //获取鼠标坐标
 4     CPoint ptCurSel(0,0);
 5     GetCursorPos(&ptCurSel);
 6     //转换为当前控件坐标系的坐标
 7     m_ctltThreadList.ScreenToClient(&ptCurSel);
 8     LVHITTESTINFO HitTestInfo;
 9     HitTestInfo.pt = ptCurSel;   
10     //判断坐标命中第几项
11     int nItem = m_ctltThreadList.HitTest(&HitTestInfo);
12     
13     //如果有选中项
14     if (nItem != -1)
15     {
16         //读取选中项内容
17         char szTmp[MAX_PATH];
18         m_ctltThreadList.GetItemText(nItem, 0, szTmp, MAX_PATH);
19         DWORD dwThreadID = strtoul(szTmp, NULL, 10);
20 
21         HMODULE hDll = LoadLibrary("Kernel32.dll");
22         _OPENTHREAD OpenThread = (_OPENTHREAD)GetProcAddress(hDll, "OpenThread");
23         m_hThread = OpenThread(THREAD_ALL_ACCESS, FALSE, dwThreadID);
24 
25         //弹出菜单
26         CMenu menu;
27         menu.LoadMenu(IDR_THREAD_MENU);
28         CPoint point;
29         GetCursorPos(&point);
30         CMenu* pSubMenu = menu.GetSubMenu(0);
31         pSubMenu->TrackPopupMenu(TPM_LEFTALIGN, point.x, point.y, this);        
32     }
33     
34     *pResult = 0;
35 }

 

ListControl响应右键,弹出菜单

标签:style   blog   color   os   ar   div   sp   log   on   

原文地址:http://www.cnblogs.com/luzhiyuan/p/3971347.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!