C#自写了控件去拖动窗体怎么实现不了,麻烦帮忙看下
代码如下,不能实现拖动panel而拖动整个窗体移动,麻烦帮忙看下哪儿有问题
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace UI_CreatingADrogControlInWinformApp
{
class DragControl:Component
{
private Control handleControl;
public Control SelectControl
{
get
{
return this.handleControl;
}
set
{
this.handleControl = value;
this.handleControl.MouseDown += new MouseEventHandler(this.DragForm_MouseDown);
}
}
public static extern int SendMessage(IntPtr a, int msg, int wParam, int lParam);
public static extern bool ReleaseCapture();
private void DragForm_MouseDown(object sender, MouseEventArgs e)
{
bool flag = e.Button == MouseButtons.Left;
if (flag)
{
DragControl.ReleaseCapture();
DragControl.SendMessage(this.SelectControl.FindForm().Handle, 162, 2, 0);
}
}
}
}
把panel绝对布局后试试 DragControl.SendMessage(this.SelectControl.FindForm().Handle, 274,61458, 0); 老司车开机 发表于 2020-7-1 08:56
DragControl.SendMessage(this.SelectControl.FindForm().Handle, 274,61458, 0);
多谢大佬,可以,膜拜
页:
[1]