触摸屏下如何 长按弹出ContextMenu,谢谢!
问题:如何实现触摸屏长按弹出ContextMenu。
分析
1、有些控件是有MouseDown ,MouseUp事件的,可以通过增加一个定时器,大于一定的时间差表明是长按触摸屏,从而打开ContextMenu。
、而有些控件是没有MouseDown,MouseUp事件的,如何实现长按触摸屏打开弹出式菜单呢?
谢谢! ContextMenu 触摸屏
[解决办法]
case WM_LBUTTONDOWN:
{
SHRGINFO shrg;
shrg.cbSize = sizeof(shrg);
shrg.hwndClient = m_hWnd;
shrg.ptDown.x = LOWORD(lParam);
shrg.ptDown.y = HIWORD(lParam);
shrg.dwFlags = SHRG_RETURNCMD;
CPoint point;
point.x = shrg.ptDown.x;
point.y = shrg.ptDown.y;
if(::SHRecognizeGesture(&shrg) == GN_CONTEXTMENU)//长按键消息
{
CMenu menu;
menu.LoadMenu(IDR_MENU_DOWN);
CMenu *pPopupMenu = menu.GetSubMenu(0);
ClientToScreen(&point);
pPopupMenu->TrackPopupMenu(TPM_LEFTALIGN,point.x,point.y,this);
}
}
C++ 的版本。