コード例 #1
0
        private Window GetWindow()
        {
            var window = new Window()
            {
                Size            = new Size(_width, _height),
                Location        = Point.Empty,
                FormBorderStyle = FormBorderStyle.None,
                WindowState     = FormWindowState.Maximized,
                ShowInTaskbar   = false,
                TopMost         = true
            };

            var margins = new Dwmapi.MARGINS()
            {
                topHeight    = -1,
                bottomHeight = -1,
                leftWidth    = -1,
                rightWidth   = -1
            };

            User32.SetLayeredWindowAttributes(window.Handle, 0, 255, 2);

            Dwmapi.DwmExtendFrameIntoClientArea(window.Handle, ref margins);

            return(window);
        }
コード例 #2
0
ファイル: TitleBarTabs.cs プロジェクト: vince-koch/EasyTabs
        /// <summary>
        /// When the window's state (maximized, minimized, or restored) changes, this sets the size of the non-client area at the top of the window properly so
        /// that the tabs can be displayed.
        /// </summary>
        protected void SetFrameSize()
        {
            if (TabRenderer == null || WindowState == FormWindowState.Minimized)
            {
                return;
            }

            int topPadding;

            if (WindowState == FormWindowState.Maximized || TabRenderer.RendersEntireTitleBar)
            {
                topPadding = TabRenderer.TabHeight - TabRenderer.TopPadding - SystemInformation.CaptionHeight;
            }

            else
            {
                topPadding = TabRenderer.TabHeight - SystemInformation.CaptionHeight;
            }

            if (!TabRenderer.IsWindows10 && WindowState == FormWindowState.Maximized)
            {
                topPadding += 1;
            }

            Padding = new Padding(
                Padding.Left, topPadding > 0
                                        ? topPadding
                                        : 0, Padding.Right, Padding.Bottom);

            if (!TabRenderer.IsWindows10)
            {
                // Set the margins and extend the frame into the client area
                MARGINS margins = new MARGINS
                {
                    cxLeftWidth    = 1,
                    cxRightWidth   = 1,
                    cyBottomHeight = 1,
                    cyTopHeight    = topPadding > 0
                                                                                  ? topPadding
                                                                                  : 0
                };

                Dwmapi.DwmExtendFrameIntoClientArea(Handle, ref margins);
            }

            _nonClientAreaHeight = SystemInformation.CaptionHeight + (topPadding > 0
                                ? topPadding
                                : 0);

            if (AeroPeekEnabled)
            {
                foreach (
                    TabbedThumbnail preview in
                    Tabs.Select(tab => TaskbarManager.Instance.TabbedThumbnail.GetThumbnailPreview(tab.Content)).Where(preview => preview != null))
                {
                    preview.PeekOffset = new Vector(Padding.Left, Padding.Top - 1);
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Extend the window frame into the client area.
        /// </summary>
        private void ExtendFrameIntoClientArea()
        {
            var margins = new Margins
            {
                Left   = -1,
                Right  = -1,
                Top    = -1,
                Bottom = -1,
            };

            Dwmapi.DwmExtendFrameIntoClientArea(Window.Handle, ref margins);
        }
コード例 #4
0
ファイル: TitleBarTabs.cs プロジェクト: thijse/EasyTabs
        /// <summary>
        /// When the window's state (maximized, minimized, or restored) changes, this sets the size of the non-client area at the top of the window properly so
        /// that the tabs can be displayed.
        /// </summary>
        protected void SetFrameSize()
        {
            if (TabRenderer == null || WindowState == FormWindowState.Minimized)
            {
                return;
            }

            int topPadding;

            if (WindowState == FormWindowState.Maximized)
            {
                //topPadding = TabRenderer.TabHeight - SystemInformation.CaptionHeight;
                topPadding = TabRenderer.TabHeight - SystemInformation.CaptionHeight + TabRenderer.MaximizedWindowTabTopOffset + 1; // Todo figure out 1 fudge factor
            }

            else
            {
                //topPadding = (TabRenderer.TabHeight + SystemInformation.CaptionButtonSize.Height) - SystemInformation.CaptionHeight;
                topPadding = TabRenderer.TabHeight - SystemInformation.CaptionHeight + TabRenderer.WindowTabTopOffset - 7; // Todo figure out 5 fudge factor
            }

            Padding = new Padding(
                Padding.Left, topPadding > 0
                                        ? topPadding
                                        : 0, Padding.Right, Padding.Bottom);

            // Set the margins and extend the frame into the client area
            MARGINS margins = new MARGINS
            {
                cxLeftWidth    = 0,
                cxRightWidth   = 0,
                cyBottomHeight = 0,
                cyTopHeight    = topPadding > 0
                                                                          ? topPadding
                                                                          : 0
            };

            Dwmapi.DwmExtendFrameIntoClientArea(Handle, ref margins);

            _nonClientAreaHeight = SystemInformation.CaptionHeight + (topPadding > 0
                                ? topPadding
                                : 0);

            if (AeroPeekEnabled)
            {
                foreach (
                    TabbedThumbnail preview in
                    Tabs.Select(tab => TaskbarManager.Instance.TabbedThumbnail.GetThumbnailPreview(tab.Content)).Where(preview => preview != null))
                {
                    preview.PeekOffset = new Vector(Padding.Left, Padding.Top - 1);
                }
            }
        }
コード例 #5
0
        public static void ExtendFrameIntoClient(IntPtr hWnd, int x, int y, int width, int height)
        {
            var margins = new Margins(x, y, width, height);

            Dwmapi.DwmExtendFrameIntoClientArea(hWnd, ref margins);
        }