Esempio n. 1
0
        /// <summary>
        /// Send window resize event.
        /// </summary>
        protected void ResetSize()
        {
            if (!IsActive)
            {
                return;
            }

            // 今のサイズを記憶
            Vector2 size = GetSize();

            // 1px横幅を広げて、リサイズイベントを強制的に起こす
            WinApi.SetWindowPos(
                hWnd,
                IntPtr.Zero,
                0, 0, (int)size.x + 1, (int)size.y,
                WinApi.SWP_NOMOVE | WinApi.SWP_NOZORDER
                | WinApi.SWP_FRAMECHANGED | WinApi.SWP_NOOWNERZORDER
                | WinApi.SWP_NOACTIVATE | WinApi.SWP_ASYNCWINDOWPOS
                );

            // 元のサイズに戻す。この時もリサイズイベントは発生するはず
            WinApi.SetWindowPos(
                hWnd,
                IntPtr.Zero,
                0, 0, (int)size.x, (int)size.y,
                WinApi.SWP_NOMOVE | WinApi.SWP_NOZORDER
                | WinApi.SWP_FRAMECHANGED | WinApi.SWP_NOOWNERZORDER
                | WinApi.SWP_NOACTIVATE | WinApi.SWP_ASYNCWINDOWPOS
                );
        }
Esempio n. 2
0
 /// <summary>
 /// Set the window position.
 /// </summary>
 /// <param name="position">Position.</param>
 public void SetPosition(Vector2 position)
 {
     if (!IsActive)
     {
         return;
     }
     WinApi.SetWindowPos(
         hWnd,
         IntPtr.Zero,
         (int)position.x, (int)position.y, 0, 0,
         WinApi.SWP_NOSIZE | WinApi.SWP_NOZORDER
         | WinApi.SWP_FRAMECHANGED | WinApi.SWP_NOOWNERZORDER
         | WinApi.SWP_NOACTIVATE | WinApi.SWP_ASYNCWINDOWPOS
         );
 }
Esempio n. 3
0
 /// <summary>
 /// Set the window size.
 /// </summary>
 /// <param name="size">Size.</param>
 public void SetSize(Vector2 size)
 {
     if (!IsActive)
     {
         return;
     }
     WinApi.SetWindowPos(
         hWnd,
         IntPtr.Zero,
         0, 0, (int)size.x, (int)size.y,
         WinApi.SWP_NOMOVE | WinApi.SWP_NOZORDER
         | WinApi.SWP_FRAMECHANGED | WinApi.SWP_NOOWNERZORDER
         | WinApi.SWP_NOACTIVATE | WinApi.SWP_ASYNCWINDOWPOS
         );
 }
Esempio n. 4
0
 /// <summary>
 /// Set the window z-order (Topmost or not).
 /// </summary>
 /// <param name="isTopmost">If set to <c>true</c> is top.</param>
 public void EnableTopmost(bool isTopmost)
 {
     if (!IsActive)
     {
         return;
     }
     WinApi.SetWindowPos(
         hWnd,
         (isTopmost ? WinApi.HWND_TOPMOST : WinApi.HWND_NOTOPMOST),
         0, 0, 0, 0,
         WinApi.SWP_NOSIZE | WinApi.SWP_NOMOVE
         | WinApi.SWP_FRAMECHANGED | WinApi.SWP_NOOWNERZORDER
         | WinApi.SWP_NOACTIVATE | WinApi.SWP_ASYNCWINDOWPOS
         );
     this._isTopmost = isTopmost;
 }