After the FormBordeStyle property is set to none, the code realizes that the mouse can drag the form

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);
        }

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324849884&siteId=291194637