首页 > 移动平台 > 详细

C#运行时鼠标移动控件 - 调用Windows API(ReleaseCapture)

时间:2016-09-15 10:58:26      阅读:476      评论:0      收藏:0      [点我收藏+]
        [System.Runtime.InteropServices.DllImport("user32.dll")]
        public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
        [System.Runtime.InteropServices.DllImport("user32.dll")]
        public static extern bool ReleaseCapture();

        private void MoveControl(Control sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left && e.Clicks == 1)
            {
                ReleaseCapture();
                SendMessage(sender.Handle, 161, 2, 0);
                SendMessage(sender.Handle, 0x0202, 0, 0);
            }
            else
            {
                //添加双击或右击代码……
            }
        }

        private void button3_MouseDown(object sender, MouseEventArgs e)
        {
            MoveControl(sender as Control, e);
        }

 

C#运行时鼠标移动控件 - 调用Windows API(ReleaseCapture)

原文:http://www.cnblogs.com/ZC_Mo-Blog/p/5874487.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!