2023年7月19日发(作者:)
WPF⾃定义最⼤化及还原按钮,⽀持双击标题栏空⽩处的最⼤化及还原处理代码:
代码: StateChanged="Window_StateChanged">
代码:using System;using c;using ;using ;using ;using s;using ls;using ;using nts;using ;using ;using g;using tion;using ;namespace WpfToolbar{ ///
private void bdClose_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) {
();
}
private void Window_StateChanged(object sender, EventArgs e) { if (!isExcuted) { if (State == ) { = new BitmapImage(new Uri("Image/", ve)); State = ; } else if (State == zed) { = new BitmapImage(new Uri("Image/", ve)); State = zed; } } } }}
WindowsFullScreenHelper类代码:using System;using c;using ;using pServices;using ;using s;using p;namespace WpfToolbar{ public class WindowsFullScreenHelper { private static Window movewin; public static void SetWindowFullScrreng(Window wpfWindow) { movewin = wpfWindow; if (wpfWindow == null) { return; } if (State == zed) { State = ; += delegate { State = zed; }; } Initialized += delegate { IntPtr handle = (new WindowInteropHelper(wpfWindow)).Handle; HwndSource source = nd(handle); if (source != null) { k(WindowProc); } }; } private static IntPtr WindowProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) { switch (msg) { case 0x0024: WmGetMinMaxInfo(hwnd, lParam); // handled = true; break; } return (IntPtr)0; } private static void WmGetMinMaxInfo(IntPtr hwnd, IntPtr lParam) { var mmi = (MINMAXINFO)tructure(lParam, typeof(MINMAXINFO)); // Adjust the maximized size and position to fit the work area of the correct monitor int MONITOR_DEFAULTTONEAREST = 0x00000002; IntPtr monitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST); if (monitor != ) { var monitorInfo = new MONITORINFO(); GetMonitorInfo(monitor, monitorInfo); RECT rcWorkArea = ; RECT rcMonitorArea = tor; osition.x = ( - ); osition.y = ( - ); ize.x = ( - ); ize.y = ( - ); } ureToPtr(mmi, lParam, true); } [DllImport("user32")] internal static extern bool GetMonitorInfo(IntPtr hMonitor, MONITORINFO lpmi); ///
/// [DllImport("User32")] internal static extern IntPtr MonitorFromWindow(IntPtr handle, int flags); #region Nested type: MINMAXINFO [StructLayout(tial)] internal struct MINMAXINFO { public POINT ptReserved; public POINT ptMaxSize; public POINT ptMaxPosition; public POINT ptMinTrackSize; public POINT ptMaxTrackSize; }; #endregion #region Nested type: MONITORINFO ///
public int cbSize = (typeof(MONITORINFO)); ///
public RECT rcMonitor; ///
public RECT rcWork; ///
public int dwFlags; } #endregion #region Nested type: POINT ///
发布者:admin,转转请注明出处:http://www.yc00.com/xiaochengxu/1689717706a280652.html
评论列表(0条)