码迷,mamicode.com
首页 > 移动开发 > 详细

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

时间:2016-09-15 10:59:52      阅读:666      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!