Https://zhidao.baidu.com/question/2116834779399609987.html
[DllImport(
"user32.dll"
, EntryPoint =
"ReleaseCapture"
)]
public
static
extern
void
ReleaseCapture();
[DllImport(
"user32.dll"
, EntryPoint =
"SendMessage"
)]
public
static
extern
void
SendMessage(
int
hwnd,
int
wMsg,
int
wParam,
int
lParam);
Load the above statement into the form class file and add an event to the dragged control, such as I am a panel
privatevoidpanelForm_MouseDown(objectsender, MouseEventArgs e) { if(e.Button == MouseButtons.Left) { ReleaseCapture(); SendMessage((int)移动的对象.Handle, 0xA1, 2, 0); //是窗体自身就是 //SendMessage((int)this.Handle, 0xA1, 2, 0); //panel就是SendMessage((int)panel1.Handle, 0xA1, 2, 0); } } |
This is the Windows standard drag-and-drop event, the following, drag the time the window is flashing constantly, has been rendering the background
C # Control Drag