Пример #1
0
 private void _InitializeCaptionButtonLocation()
 {
     if (!Standard.Utility.IsOSVistaOrNewer || !Standard.NativeMethods.IsThemeActive())
     {
         this._LegacyInitializeCaptionButtonLocation();
     }
     else
     {
         Standard.TITLEBARINFOEX structure = new Standard.TITLEBARINFOEX {
             cbSize = Marshal.SizeOf(typeof(Standard.TITLEBARINFOEX))
         };
         IntPtr ptr = Marshal.AllocHGlobal(structure.cbSize);
         try
         {
             Marshal.StructureToPtr(structure, ptr, false);
             Standard.NativeMethods.ShowWindow(this._messageHwnd.Handle, Standard.SW.SHOW);
             Standard.NativeMethods.SendMessage(this._messageHwnd.Handle, Standard.WM.GETTITLEBARINFOEX, IntPtr.Zero, ptr);
             structure = (Standard.TITLEBARINFOEX)Marshal.PtrToStructure(ptr, typeof(Standard.TITLEBARINFOEX));
         }
         finally
         {
             Standard.NativeMethods.ShowWindow(this._messageHwnd.Handle, Standard.SW.HIDE);
             Standard.Utility.SafeFreeHGlobal(ref ptr);
         }
         Standard.RECT rect            = Standard.RECT.Union(structure.rgrect_CloseButton, structure.rgrect_MinimizeButton);
         Standard.RECT windowRect      = Standard.NativeMethods.GetWindowRect(this._messageHwnd.Handle);
         Rect          deviceRectangle = new Rect((double)((rect.Left - windowRect.Width) - windowRect.Left), (double)(rect.Top - windowRect.Top), (double)rect.Width, (double)rect.Height);
         Rect          rect4           = Standard.DpiHelper.DeviceRectToLogical(deviceRectangle);
         this.WindowCaptionButtonsLocation = rect4;
     }
 }
Пример #2
0
 private Standard.HRESULT _UpdateThumbnailClipping(bool attached)
 {
     Standard.RefRECT prcClip = null;
     if (attached && (this.ThumbnailClipMargin != _EmptyThickness))
     {
         Thickness     thumbnailClipMargin = this.ThumbnailClipMargin;
         Standard.RECT clientRect          = Standard.NativeMethods.GetClientRect(this._hwndSource.Handle);
         Rect          rect2 = Standard.DpiHelper.DeviceRectToLogical(new Rect((double)clientRect.Left, (double)clientRect.Top, (double)clientRect.Width, (double)clientRect.Height));
         if (((thumbnailClipMargin.Left + thumbnailClipMargin.Right) >= rect2.Width) || ((thumbnailClipMargin.Top + thumbnailClipMargin.Bottom) >= rect2.Height))
         {
             prcClip = new Standard.RefRECT(0, 0, 0, 0);
         }
         else
         {
             Rect logicalRectangle = new Rect(thumbnailClipMargin.Left, thumbnailClipMargin.Top, (rect2.Width - thumbnailClipMargin.Left) - thumbnailClipMargin.Right, (rect2.Height - thumbnailClipMargin.Top) - thumbnailClipMargin.Bottom);
             Rect rect4            = Standard.DpiHelper.LogicalRectToDevice(logicalRectangle);
             prcClip = new Standard.RefRECT((int)rect4.Left, (int)rect4.Top, (int)rect4.Right, (int)rect4.Bottom);
         }
     }
     return(this._taskbarList.SetThumbnailClip(this._hwndSource.Handle, prcClip));
 }
Пример #3
0
 private static extern bool _GetWindowRect(IntPtr hWnd, out RECT lpRect);
Пример #4
0
 public static IntPtr CreateRectRgnIndirect(RECT lprc)
 {
     IntPtr ret = _CreateRectRgnIndirect(ref lprc);
     if (IntPtr.Zero == ret)
     {
         throw new Win32Exception();
     }
     return ret;
 }
Пример #5
0
        public static RECT AdjustWindowRectEx(RECT lpRect, WS dwStyle, bool bMenu, WS_EX dwExStyle)
        {
            // Native version modifies the parameter in place.
            if (!_AdjustWindowRectEx(ref lpRect, dwStyle, bMenu, dwExStyle))
            {
                HRESULT.ThrowLastError();
            }

            return lpRect;
        }
Пример #6
0
 private static extern bool _AdjustWindowRectEx(ref RECT lpRect, WS dwStyle, [MarshalAs(UnmanagedType.Bool)] bool bMenu, WS_EX dwExStyle);
Пример #7
0
 public static RECT Union(RECT rect1, RECT rect2)
 {
     return new RECT
     {
         Left = Math.Min(rect1.Left, rect2.Left),
         Top = Math.Min(rect1.Top, rect2.Top),
         Right = Math.Max(rect1.Right, rect2.Right),
         Bottom = Math.Max(rect1.Bottom, rect2.Bottom),
     };
 }
        private RECT _GetAdjustedWindowRect(RECT rcWindow)
        {
            // This should only be used to work around issues in the Framework that were fixed in 4.0
            Assert.IsTrue(Utility.IsPresentationFrameworkVersionLessThan4);

            var style = (WS)NativeMethods.GetWindowLongPtr(_hwnd, GWL.STYLE);
            var exstyle = (WS_EX)NativeMethods.GetWindowLongPtr(_hwnd, GWL.EXSTYLE);

            return NativeMethods.AdjustWindowRectEx(rcWindow, style, false, exstyle);
        }
Пример #9
0
        private static RECT AdjustWorkingAreaForAutoHide(IntPtr monitorContainingApplication, RECT area)
        {
            // maybe we can use ReBarWindow32 isntead Shell_TrayWnd
            IntPtr hwnd = NativeMethods.FindWindow("Shell_TrayWnd", null);
            IntPtr monitorWithTaskbarOnIt = NativeMethods.MonitorFromWindow(hwnd, (uint)MonitorOptions.MONITOR_DEFAULTTONEAREST);

            var abd = new APPBARDATA();
            abd.cbSize = Marshal.SizeOf(abd);
            abd.hWnd = hwnd;
            NativeMethods.SHAppBarMessage((int)ABMsg.ABM_GETTASKBARPOS, ref abd);
            bool autoHide = Convert.ToBoolean(NativeMethods.SHAppBarMessage((int)ABMsg.ABM_GETSTATE, ref abd));

            if (!autoHide || !Equals(monitorContainingApplication, monitorWithTaskbarOnIt))
            {
                return area;
            }

            switch (abd.uEdge)
            {
                case (int)ABEdge.ABE_LEFT:
                    area.Left += 2;
                    break;
                case (int)ABEdge.ABE_RIGHT:
                    area.Right -= 2;
                    break;
                case (int)ABEdge.ABE_TOP:
                    area.Top += 2;
                    break;
                case (int)ABEdge.ABE_BOTTOM:
                    area.Bottom -= 2;
                    break;
                default:
                    return area;
            }
            return area;
        }
Пример #10
0
 public static extern bool GetWindowRect(IntPtr hWnd, out RECT lpRect);