wince的.netcf让pda界面支持右键(c#版本)

Recently i wanted to implement contextmenu withanimation(progress) though there is no direct api or way to do it after hoursof searching on the net i finally found a hack to do it by using win32 dll byP/invoking SHRecognizeGesture in aygshell.dll below pic shows the example ofcontext menu in calendar week view

c8df066d62cc1e37ccf4b6a1d1db70bb.jpg

// Initialize the below code snippet in thebeginning of the class
     internal struct SHRGINFO
     {
         public int cbSize;
         public IntPtr hwndClient;
         public int ptDownX;
         public int ptDownY;
         public SHRGFLags dwFlags;
     }
     
     [Flags]
     internal enum SHRGFLags
     {
         SHRG_RETURNCMD = 0x00000001,
         SHRG_NOTIFYPARENT = 0x00000002,
         SHRG_LONGDELAY = 0x00000008,
         SHRG_NOANIMATION = 0x00000010,
     }
     [DllImport("aygshell")]
     extern private static intSHRecognizeGesture(ref SHRGINFO shr);

     [DllImport("coredll.dll",SetLastError = true)]
     public static extern IntPtr GetActiveWindow();


     //call the showContMenu() method inMouseup or MouseDown event
     public void showContMenu(int x, inty)
     {
         SHRGINFO shr = new SHRGINFO();
         shr.cbSize =Marshal.SizeOf(typeof(SHRGINFO));
         shr.dwFlags = SHRGFLags.SHRG_RETURNCMD;
         shr.ptDownX = x;
         shr.ptDownY = y;
         shr.hwndClient =GetActiveWindow();

         int ret = SHRecognizeGesture(refshr);

         if (ret == 1000)
             contextMenu1.Show(this, newSystem.Drawing.Point(x, y));

     }


I have used above method in more than two views and it works awesome, if youhave any problem with above snippet you can reach me through email at thebottom of the page and if there is a better way or if managed code exists sharewith us.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值