ppc中长时间点击的响应(长按)

SHRGINFO

This structure sets members for the SHRecognizeGesture function. If a user taps and holds long enough to warrant a context menu, a GN_CONTEXTMENU notification will be returned by the function, or sent to the parent of the control, depending on the values in the SHRGINFO structure.
typedef struct tagSHRGI {
DWORD cbSize;
HWND hwndClient;
POINT ptDown
DWORD dwFlags;
} SHRGINFO, *PSHRGINFO;
Members
cbSize
Sizeof (SHRGINFO).
hwndClient
Handle to the window calling the SHRecognizeGesture function.
ptDown
X and Y client coordinates of the mouse-down position.
dwFlags
Contains one of the values listed in the following table.

Flag
Description
SHRG_RETURNCMD
Return value will be GN_CONTEXTMENU or 0 (zero).
SHRG_NOTIFYPARENT
Parent of hwndClient will receive WM_NOTIFY/ GN_CONTEXTMENU.
SHRG_LONGDELAY
This will process a longer delay than the default before it indicates a gesture.

点击右键
在Windows系统里,当您在一个对象上单击鼠标右键,通常地会调出上下文相关的、独立的菜单,显示针对该具体对象能做什么的功能项集合。在有鼠标的系统中,Windows发送WM_RBUTTONDOWN和WM_RBUTTONUP消息,指出右键点击了。但是当使用手写笔的时候,不会有右键。不过Windows CE指导方针中允许您使用手写笔模拟右键点击。指导方针规定,如果用户按下Alt键的同时用手写笔点击屏幕,程序会当成是右键鼠标被点击,并显示相关的上下文菜单。在WM_LBUTTONDOWN的wParam中没有MK_ALT标志,所以判断Alt键是否被按的最好方法是用VK_MENU做参数调用GetKeyState,并测试返回值的相关位是否被设置了。在这种情况下,GetKeyState是最合适的,因为返回的是鼠标消息从消息队列里取出时的键的状态。
在没有键盘的系统上,采取压下并保持这一姿势来模拟鼠标右键点击。SHRecognizeGesture函数可以用在Pocket PC和具有适当Shell组件的嵌入式Windows CE系统中,用来检查压下并保持这一姿势。函数原型如下:
WINSHELLAPI DWORD SHRecongnizeGesture(SHRGINFO * shrg);
唯一的参数是一SHRGINFO结构的地址,该结构定义如下:
typedef struct tagSHRGI{
DWORD cbSize;
HWND hwndClient;
POINT ptDown;
DWORD dwFlags;
}SHRGINFO,*PSHRGINFO;

cbSize需要用结构的大小来填充。hwndClient则需要设置为调用该函数的窗口的句柄。ptDown结构需要用识别出姿势时的点来填充。dwFlags则包含许多标志。SHRG_RETURNCMD标志表示如果用户做出正确的下压保持姿势,则让函数返回GN_CONTEXTMENU;否则就返回0SHRG_NOTIFYPARENT标志表示如果识别出正确姿势的话,就给父窗口发送一个WM_NOTIFY消息。SHRG_LONDELAY消息要求在识别出姿势之前,用户需要保持点压一段时间。 

 

SHRecognizeGesture
This function is typically used by custom controls to recognize certain stylus gestures. The one currently supported gesture is for context menus, where a context menu gesture is defined as when the user presses and holds the stylus in the same spot for some short period of time.
WINSHELLAPI DWORD SHRecognizeGesture(
SHRGINFO * shrg);
Parameters
shrg
Pointer to a SHRGINFO structure.
Return Values
Returns 0 if there was no context menu gesture. If there was a context menu gesture, then one of the following will be returned:
If the dwFlags member of the SHRG structure is SHRG_RETURNCMD, the function will return GN_CONTEXTMENU .
If the dwFlags member of the SHRG structure is SHRG_NOTIFYPARENT, a WM_NOTIFY with GN_CONTEXTMENU will be sent to the parent of shrg->hwndClient, and the function will return whatever the return value from the WM_NOTIFY processing is.
A WM_NOTIFY with GN_CONTEXTMENU will be sent to shrg->hwndClient, and the function will return whatever the return value from the WM_NOTIFY processing is.
Remarks
Typically, a control will call this function during the WM_LBUTTONDOWN processing. If the user presses and holds long enough to warrant a context menu, a GN_CONTEXTMENU notification will be returned by the function, or sent to the parent of the control, depending on the values in the SHRG structure. Note that it is the responsibility of the application processing the GN_CONTEXTMENU notification to bring up the menu.
 
例子:
void CCeButtonST::OnLButtonDown(UINT nFlags, CPoint point)
{
       //==================
       SHRGINFO    shrg;
   
    shrg.cbSize = sizeof(shrg);
    shrg.hwndClient = m_hWnd;
    shrg.ptDown.x = point.x;//LOWORD(lParam);
    shrg.ptDown.y = point.y;//HIWORD(lParam);
shrg.dwFlags = SHRG_RETURNCMD;
// |SHRG_NOANIMATION |SHRG_LONGDELAY
   
    if (::SHRecognizeGesture(&shrg) == GN_CONTEXTMENU)
    {
              //MessageBox(_T("ok"));
              if(m_StSound!=_T(""))
              {
                     PlaySound(m_StSound,NULL,SND_ASYNC);
              }
              #if defined(_WIN32_WCE_PSPC) && (_WIN32_WCE >= 300)
                     SHRecognizeGesture(point);//是否显示圆圈
        #endif // _WIN32_WCE_PSPC
       }else
       {
       //==================
       SetState(TRUE);
#if defined(_WIN32_WCE_PSPC) && (_WIN32_WCE >= 300)
       SHRecognizeGesture(point);
#endif // _WIN32_WCE_PSPC
       Default();
       }
      
       //CButton::OnLButtonDown(nFlags, point);
} // End of OnLButtonDown
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值