コード例 #1
0
        /// <summary>
        /// 禁用最大最小化按钮并隐藏
        /// </summary>
        /// <param name="w"></param>
        public static void HideMinimizeAndMaximizeBoxes(this Window w)
        {
            IntPtr hwnd = new WindowInteropHelper(w).Handle;

            WindowApiHelper.SetWindowLong(hwnd, WindowStaticMacro.GWL_STYLE,
                                          WindowApiHelper.GetWindowLong(hwnd, WindowStaticMacro.GWL_STYLE) & ~(WindowStaticMacro.WS_MAXIMIZEBOX | WindowStaticMacro.WS_MINIMIZEBOX));
        }
コード例 #2
0
        /// <summary>
        /// 隐藏标题栏(包括ICon, titlebar的右键菜单, 三个系统窗口按钮)
        /// </summary>
        /// <param name="w"></param>
        public static void HideSysMenu(this Window w)
        {
            IntPtr hwnd          = new WindowInteropHelper(w).Handle;
            int    extendedStyle = WindowApiHelper.GetWindowLong(hwnd, WindowStaticMacro.GWL_EXSTYLE);

            WindowApiHelper.SetWindowLong(hwnd, WindowStaticMacro.GWL_EXSTYLE, extendedStyle | WindowStaticMacro.WS_EX_DLGMODALFRAME);
            WindowApiHelper.SetWindowPos(hwnd, IntPtr.Zero, 0, 0, 0, 0, WindowStaticMacro.SWP_NOMOVE | WindowStaticMacro.SWP_NOSIZE | WindowStaticMacro.SWP_NOZORDER | WindowStaticMacro.SWP_FRAMECHANGED);
        }
コード例 #3
0
        /// <summary>
        /// 移除Icon
        /// </summary>
        /// <param name="window"></param>
        public static void RemoveIcon(this Window window)
        {
            // Get this window's handle
            IntPtr hwnd = new WindowInteropHelper(window).Handle;
            // Change the extended window style to not show a window icon
            int extendedStyle = WindowApiHelper.GetWindowLong(hwnd, WindowStaticMacro.GWL_EXSTYLE);

            WindowApiHelper.SetWindowLong(hwnd, WindowStaticMacro.GWL_EXSTYLE, extendedStyle | WindowStaticMacro.WS_EX_DLGMODALFRAME);
            // Update the window's non-client area to reflect the changes
            WindowApiHelper.SetWindowPos(hwnd, IntPtr.Zero, 0, 0, 0, 0, WindowStaticMacro.SWP_NOMOVE | WindowStaticMacro.SWP_NOSIZE |
                                         WindowStaticMacro.SWP_NOZORDER | WindowStaticMacro.SWP_FRAMECHANGED);
        }