コード例 #1
0
        /// <summary>
        /// Centers the window in the screen. You must call it after the window is created, but before it is shown to avoid flickering
        /// </summary>
        public void CenterTopLevelWindow()
        {
#if WINDOWS
            PInvokeUtils.RECT rectWindow;
            PInvokeWindows.GetWindowRect(_hwnd, out rectWindow);

            PInvokeUtils.RECT rectWorkArea = new PInvokeUtils.RECT();
            PInvokeWindows.SystemParametersInfo(PInvokeWindows.SPI_GETWORKAREA, 0, ref rectWorkArea, 0);

            int nX = (rectWorkArea.Width - rectWindow.Width) / 2 + rectWorkArea.left;
            int nY = (rectWorkArea.Height - rectWindow.Height) / 2 + rectWorkArea.top;

            PInvokeWindows.MoveWindow(_hwnd, nX, nY, rectWindow.Width, rectWindow.Height, false);
#elif GTKMONO
            int screen_width  = PInvokeGTK.gdk_screen_width();
            int screen_height = PInvokeGTK.gdk_screen_height();

            int window_width, window_height;
            PInvokeGTK.gtk_window_get_size(_gtkwindow, out window_width, out window_height);

            int nX = (screen_width - window_width) / 2;
            int nY = (screen_height - window_height) / 2;

            PInvokeGTK.gtk_window_move(_gtkwindow, nX, nY);
#elif OSX
            _nsview.Window.Center();
#endif
        }
コード例 #2
0
ファイル: SciterControl.cs プロジェクト: wdcossey/SciterCore
 protected override void OnClientSizeChanged(EventArgs e)
 {
     if (Host?.Window != null && Host?.Window?.Handle != IntPtr.Zero)
     {
         var clientSize = this.Size;
         PInvokeWindows.MoveWindow(hWnd: Host.Window.Handle, X: 0, Y: 0, nWidth: clientSize.Width, nHeight: clientSize.Height, bRepaint: true);
     }
     base.OnClientSizeChanged(e: e);
 }
コード例 #3
0
 protected override void OnClientSizeChanged(EventArgs e)
 {
     if (SciterWnd._hwnd.ToInt32() != 0)
     {
         var sz = this.Size;
         PInvokeWindows.MoveWindow(SciterWnd._hwnd, 0, 0, sz.Width, sz.Height, true);
     }
     base.OnClientSizeChanged(e);
 }
コード例 #4
0
ファイル: SciterControl.cs プロジェクト: wdcossey/SciterCore
 protected override void OnClientSizeChanged(EventArgs e)
 {
     if (SciterWindow != null && SciterWindow?.Handle != IntPtr.Zero)
     {
         var sz = this.Size;
         PInvokeWindows.MoveWindow(hWnd: SciterWindow.Handle, X: this.Left, Y: this.Top, nWidth: sz.Width, nHeight: sz.Height, bRepaint: true);
     }
     base.OnClientSizeChanged(e);
 }
コード例 #5
0
            /*
             #if WINDOWS || NETCORE
             * public bool ModifyStyle(PInvokeWindows.WindowStyles dwRemove, PInvokeWindows.WindowStyles dwAdd)
             * {
             *      int GWL_EXSTYLE = -20;
             *
             *      PInvokeWindows.WindowStyles dwStyle =
             *              (PInvokeWindows.WindowStyles) PInvokeWindows.GetWindowLongPtr(Handle, GWL_EXSTYLE);
             *      PInvokeWindows.WindowStyles dwNewStyle = (dwStyle & ~dwRemove) | dwAdd;
             *
             *      if (dwStyle == dwNewStyle)
             *              return false;
             *
             *      PInvokeWindows.SetWindowLongPtr(Handle, GWL_EXSTYLE, (IntPtr) dwNewStyle);
             *      return true;
             * }
             *
             * public bool ModifyStyleEx(PInvokeWindows.WindowStyles dwRemove, PInvokeWindows.WindowStyles dwAdd)
             * {
             *      int GWL_STYLE = -16;
             *
             *      PInvokeWindows.WindowStyles dwStyle =
             *              (PInvokeWindows.WindowStyles) PInvokeWindows.GetWindowLongPtr(Handle, GWL_STYLE);
             *      PInvokeWindows.WindowStyles dwNewStyle = (dwStyle & ~dwRemove) | dwAdd;
             *      if (dwStyle == dwNewStyle)
             *              return false;
             *
             *      PInvokeWindows.SetWindowLongPtr(Handle, GWL_STYLE, (IntPtr) dwNewStyle);
             *      return true;
             * }
             #endif*/

            /// <summary>
            /// Centers the window in the screen. You must call it after the window is created, but before it is shown to avoid flickering
            /// </summary>
            public void CenterWindow(IntPtr handle)
            {
                PInvokeWindows.GetWindowRect(handle, out var rectWindow);

                var rectWorkArea = new PInvokeUtils.RECT();

                PInvokeWindows.SystemParametersInfo(PInvokeWindows.SPI_GETWORKAREA, 0, ref rectWorkArea, 0);

                var newX = (rectWorkArea.Width - rectWindow.Width) / 2 + rectWorkArea.Left;
                var newY = (rectWorkArea.Height - rectWindow.Height) / 2 + rectWorkArea.Top;

                PInvokeWindows.MoveWindow(handle, newX, newY, rectWindow.Width, rectWindow.Height, false);
            }
コード例 #6
0
        /// <summary>
        /// Centers the window in the screen. You must call it after the window is created, but before it is shown to avoid flickering
        /// </summary>
        public void CenterTopLevelWindow()
        {
#if WINDOWS
            IntPtr            hwndParent = PInvokeWindows.GetDesktopWindow();
            PInvokeUtils.RECT rectWindow, rectParent;

            PInvokeWindows.GetWindowRect(_hwnd, out rectWindow);
            PInvokeWindows.GetWindowRect(hwndParent, out rectParent);

            int nWidth = rectWindow.right - rectWindow.left;
            int nHeight = rectWindow.bottom - rectWindow.top;

            int nX = ((rectParent.right - rectParent.left) - nWidth) / 2 + rectParent.left;
            int nY = ((rectParent.bottom - rectParent.top) - nHeight) / 2 + rectParent.top;

            int nScreenWidth  = PInvokeWindows.GetSystemMetrics(PInvokeWindows.SystemMetric.SM_CXSCREEN);
            int nScreenHeight = PInvokeWindows.GetSystemMetrics(PInvokeWindows.SystemMetric.SM_CYSCREEN);

            if (nX < 0)
            {
                nX = 0;
            }
            if (nY < 0)
            {
                nY = 0;
            }
            if (nX + nWidth > nScreenWidth)
            {
                nX = nScreenWidth - nWidth;
            }
            if (nY + nHeight > nScreenHeight)
            {
                nY = nScreenHeight - nHeight;
            }

            PInvokeWindows.MoveWindow(_hwnd, nX, nY, nWidth, nHeight, false);
#elif GTKMONO
            int screen_width  = PInvokeGTK.gdk_screen_width();
            int screen_height = PInvokeGTK.gdk_screen_height();

            int window_width, window_height;
            PInvokeGTK.gtk_window_get_size(_gtkwindow, out window_width, out window_height);

            int nX = (screen_width - window_width) / 2;
            int nY = (screen_height - window_height) / 2;

            PInvokeGTK.gtk_window_move(_gtkwindow, nX, nY);
#elif OSX
            _nsview.Window.Center();
#endif
        }
コード例 #7
0
            public void SetPosition(IntPtr handle, SciterPoint point)
            {
                var size = Size(handle);

                PInvokeWindows.MoveWindow(handle, point.X, point.Y, size.Width, size.Height, false);
            }