After dragging, we found two methods:
1,
Private Point myPoint;
Private void form=mousemove (object sender, MouseEventArgs e)
{
If (e. Button = MouseButtons. Left)
{
Point myPosition = Control. MousePosition;
MyPosition. Offset (myPoint. X, myPoint. Y );
This. Specify toplocation = myPosition;
}
}
Private void form=mouseup (object sender, MouseEventArgs e)
{
If (e. Button = MouseButtons. Left)
{
Point myPosition = Control. MousePosition;
MyPosition. Offset (myPoint. X, myPoint. Y );
This. Specify toplocation = myPosition;
}
}
Private void form=mousedown (object sender, MouseEventArgs e)
{
MyPoint = new Point (-e. X,-e. Y );
}
In this method, three events Form1_MouseMove, Form1_MouseUp, and Form1_MouseDown are added, which can be implemented but there is a shadow in the drag process.
2,
[System. Runtime. InteropServices. DllImport ("user32.dll")]
Public static extern bool ReleaseCapture ();
[System. Runtime. InteropServices. DllImport ("user32.dll")]
Public static extern bool SendMessage (IntPtr hwnd, int wMsg, int wParam, int lParam );
Public const int WM_SYSCOMMAND = 0x0112;
Public const int SC _MOVE = 0xF010;
Public const int HTCAPTION = 0x0002;
Private void form=mousedown (object sender, MouseEventArgs e)
{
Try
{
ReleaseCapture ();
SendMessage (this. Handle, WM_SYSCOMMAND, SC _MOVE + HTCAPTION, 0 );
}
Catch
{}
}
This method has no effect.
Author: "column of yysyangyangyangshan"