首页 > 代码库 > C#运行时鼠标移动控件 - 调用Windows API(ReleaseCapture)
C#运行时鼠标移动控件 - 调用Windows API(ReleaseCapture)
[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)
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。