private void ToggleFullScreen() { if (!isFullScreen) { isMaximized = User32Methods.IsZoomed(Handle); //if (isMaximized) // SetState(ShowWindowCommands.SW_RESTORE); windowStyles = GetStyles(); windowExStyles = GetExStyles(); GetWindowRect(out windowRect); SetStyle(windowStyles & ~(WindowStyles.WS_CAPTION | WindowStyles.WS_THICKFRAME)); SetExStyles(windowExStyles & ~(WindowExStyles.WS_EX_DLGMODALFRAME | WindowExStyles.WS_EX_WINDOWEDGE | WindowExStyles.WS_EX_CLIENTEDGE | WindowExStyles.WS_EX_STATICEDGE)); IntPtr monitor = User32Methods.MonitorFromWindow(Handle, MonitorFlag.MONITOR_DEFAULTTONEAREST); User32Helpers.GetMonitorInfo(monitor, out MonitorInfo monitorInfo); SetPosition(monitorInfo.MonitorRect, WindowPositionFlags.SWP_NOZORDER | WindowPositionFlags.SWP_NOACTIVATE | WindowPositionFlags.SWP_FRAMECHANGED); } else { SetStyle(windowStyles); SetExStyles(windowExStyles); SetPosition(windowRect, WindowPositionFlags.SWP_NOZORDER | WindowPositionFlags.SWP_NOACTIVATE | WindowPositionFlags.SWP_FRAMECHANGED); if (isMaximized) { SetState(ShowWindowCommands.SW_MAXIMIZE); } } isFullScreen = !isFullScreen; ResetTransformation(); }