Winform 无边框窗体双击放大缩小

废话不多说,直接上代码(talk is cheap,show me the code)


       

    
        [DllImport("user32.dll")] //Namespace System.Runtime.InteropServices;
        public static extern bool ReleaseCapture(); //release the mouse capture from a window in the current thread 

        //Send the specified message to a window,
        //The SendMessage fuction  calls the window procedure for the specified window and dose not return until  the window procedure has processed the message
        [DllImport("user32.dll")]
        public const int WM_SYSCOMMAND = 0x0112;
        public const int SC_MAXIMIZE = 0xF030;
        public const int SC_RESTORE = 0xF120;

        private void btn_title_MouseDown(object sender, MouseEventArgs e)
        {
    
    
 
            if (e.Clicks == 2)
            {
    
    
                if (WindowState == FormWindowState.Maximized)
                {
    
    
                    // Restore the form
                    ReleaseCapture();
                    SendMessage(Handle, WM_SYSCOMMAND, SC_RESTORE, 0);
                }
                else if (WindowState == FormWindowState.Normal)
                {
    
    
                    //Maximize the form
                    ReleaseCapture();
                    SendMessage(Handle, WM_SYSCOMMAND, SC_MAXIMIZE, 0);
                }
            }
        }

猜你喜欢

转载自blog.csdn.net/q913777031/article/details/118326801
今日推荐