Пример #1
0
        public void SetPosition(IntPtr hWnd, int x, int y, int width, int height)
        {
            USER32.SWP param = USER32.SWP.NOACTIVATE;
            if (width + height <= 0)
            {
                param |= USER32.SWP.NOSIZE;
            }

            USER32.SetWindowPos(hWnd, IntPtr.Zero, x, y, width, height, USER32.SWP.NOACTIVATE);
        }
Пример #2
0
        /************************************************************************************/
        protected override void OnSourceInitialized(EventArgs e)
        {
            base.OnSourceInitialized(e);

            /// This value is constant for the life of the window.
            m_hWin32Window = new WindowInteropHelper(this).Handle;

            /// This doesn't work. I don't know why.

            /*
             * if (m_bShowMinimizeButton)
             *      ChangeStyle(USER32.WindowStyles.MinimizeBox, 0);
             * else
             *      ChangeStyle(0, USER32.WindowStyles.MinimizeBox);
             */

            if (m_bShowSystemMenu)
            {
                ChangeExStyle(0, USER32.WindowStylesEx.DialogModalFrame);
            }
            else
            {
                ChangeExStyle(USER32.WindowStylesEx.DialogModalFrame, 0);
            }

            const USER32.SetWindowPosFlags eSetWindowPosFlags =
                USER32.SetWindowPosFlags.NoMove |
                USER32.SetWindowPosFlags.NoSize |
                USER32.SetWindowPosFlags.NoZOrder |
                USER32.SetWindowPosFlags.FrameChanged;

            USER32.SetWindowPos(m_hWin32Window, IntPtr.Zero, 0, 0, 0, 0, eSetWindowPosFlags);

            EnableDisableControls();

            if (s_fUniversalScale != null)
            {
                Scale = s_fUniversalScale.Value;
            }
            return;
        }