110,539
社区成员
发帖
与我相关
我的任务
分享
this.Capture = false;
Message msg = Message.Create(Handle, WM_Move, (IntPtr)WM_SIZE, (IntPtr)HTLEFT);
WndProc(ref msg);
ReleaseCapture();
const int WM_SIZE=0x06;
const int WM_Move = 0x06;
const int HTLEFT = 10;
const int WM_SYSCOMMAND = 0x0112;
SendMessage(this.Handle, WM_SYSCOMMAND, (IntPtr)(WM_Move + WM_SIZE), "");
protected override CreateParams CreateParams
{
get
{
CreateParams cp= base.CreateParams;
cp.Style |= (int)0x00040000;
return cp;
}
}
[System.Runtime.InteropServices.DllImport("user32.dll")]
private static extern IntPtr SendMessage(IntPtr hWnd, int msg, int wparam, int lparam);
protected override void OnMouseDown(MouseEventArgs e)
{
base.OnMouseDown(e);
if (e.Button == MouseButtons.Left)//按下的是鼠标左键
{
Capture = false;//释放鼠标,使能够手动操作
SendMessage(this.Handle, 0x00A1, 2, 0);//拖动窗体
}
}