110,534
社区成员
发帖
与我相关
我的任务
分享
protected override void OnMouseMove(System.Windows.Forms.MouseEventArgs e)
{
if (moveFlag && (e.Button == MouseButtons.Left))
this.SetBounds(Left + e.X - x, Top + e.Y - y, this.Width, this.Height);
base.OnMouseMove(e);
}
protected override void OnMouseDown(System.Windows.Forms.MouseEventArgs e)
{
if (!moveFlag && e.Clicks >= 1)
moveFlag = true;
x = e.X;
y = e.Y;
base.OnMouseDown(e);
}
protected override void OnMouseUp(System.Windows.Forms.MouseEventArgs e)
{
if (moveFlag)
moveFlag = false;
base.OnMouseUp(e);
}
protected override void OnMouseUp(System.Windows.Forms.MouseEventArgs e)
{
if (moveFlag)
moveFlag = false;
base.OnMouseUp(e);
f.Hide();
Form3 f31 = new Form3(this);
f31.Show();
f = f31;
}
[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);//拖动窗体
}
}
protected override void WndProc(ref Message m)
{
if (m.Msg == 163 && this.ClientRectangle.Contains(this.PointToClient(new Point(m.LParam.ToInt32()))) && m.WParam.ToInt32() == 2)
m.WParam = (IntPtr)1;
base.WndProc(ref m);
if (m.Msg == 132 && m.Result.ToInt32() == 1)
m.Result = (IntPtr)2;
}