111,092
社区成员




using System;
using System.Windows.Forms;
namespace YourNamespace
{
public static class Class1
{
private const int WM_NCLBUTTONDOWN = 0x00A1;
private const int WM_NCHITTEST = 0x84;
private const int HT_CAPTION = 0x2;
private const int HT_CLIENT = 0x1;
public delegate void WndProDelegate(ref Message x);
public static void MyDragMove(this Control ctl, IntPtr Handle, WndProDelegate wndpro)
{
ctl.Capture = false;
Message msg = Message.Create(Handle, WM_NCLBUTTONDOWN, (IntPtr)HT_CAPTION, IntPtr.Zero);
wndpro(ref msg);
}
}
}
那么在Form中可以这样调用:pictureBox1.MyDragMove(this.Handle, this.WndProc);
public class test
{
public int WM_NCLBUTTONDOWN
{
get { return 0x00A1; }
}
}