Add the following code to the background code of the form whose FormBordeStyle property is set to none to realize the moving function when the mouse drags the form:
/// <summary>
/// After setting FormBorderStyle:FixedDialog, the form cannot be moved, and the mobile window is re-implemented Body code
/// </summary>
private const int WM_NCHITTEST = 0x84;
private const int HTCLIENT = 0x1;
private const int HTCAPTION = 0x2;
protected override void WndProc(ref Message id)
{
// Reference message ID(ref Message ID)
switch (id.Msg)
{
case WM_NCHITTEST:
base.WndProc(ref id);
if ((int)id.Result == HTCLIENT)
id.Result = (IntPtr)HTCAPTION;
return;
}
base.WndProc(ref id);
}
/// <summary>
/// After setting FormBorderStyle:FixedDialog, the form cannot be moved, and the mobile window is re-implemented Body code
/// </summary>
private const int WM_NCHITTEST = 0x84;
private const int HTCLIENT = 0x1;
private const int HTCAPTION = 0x2;
protected override void WndProc(ref Message id)
{
// Reference message ID(ref Message ID)
switch (id.Msg)
{
case WM_NCHITTEST:
base.WndProc(ref id);
if ((int)id.Result == HTCLIENT)
id.Result = (IntPtr)HTCAPTION;
return;
}
base.WndProc(ref id);
}