コード例 #1
0
        public static void SetPlacement(this Window window, WindowNativeMethods.WINDOWPLACEMENT windowPlacement)
        {
            windowPlacement.length = (uint)Marshal.SizeOf(typeof(WindowNativeMethods.WINDOWPLACEMENT));
            windowPlacement.flags = 0;
            GCHandle lpwndpl = GCHandle.Alloc(windowPlacement, GCHandleType.Pinned);

            bool success = WindowNativeMethods.SetWindowPlacement(new WindowInteropHelper(window).Handle, ref windowPlacement);

            lpwndpl.Free();

            if (!success)
            {
                throw new InvalidOperationException("Setting window placement failed.");
            }
        }
コード例 #2
0
        public static void SetPlacement(this Window window, WindowNativeMethods.WINDOWPLACEMENT windowPlacement)
        {
            windowPlacement.length = (uint)Marshal.SizeOf(typeof(WindowNativeMethods.WINDOWPLACEMENT));
            windowPlacement.flags  = 0;
            GCHandle lpwndpl = GCHandle.Alloc(windowPlacement, GCHandleType.Pinned);

            bool success = WindowNativeMethods.SetWindowPlacement(new WindowInteropHelper(window).Handle, ref windowPlacement);

            lpwndpl.Free();

            if (!success)
            {
                throw new InvalidOperationException("Setting window placement failed.");
            }
        }