Windows Mobile开发快捷菜单问题
今天在开发群里又有人问到ppc上如何长按弹出快捷菜单。
与windows不同的是,ppc并不依靠响应WM_RBUTTONDOWN消息来实现,而是在WM_LBUTTONDOWN来处理。说来也不奇怪,ppc上根本就没有右键。
以下是正确的代码:
......
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);
}
}
......