internal static bool GetClientSize(IntPtr hwnd, out System.Drawing.Size size)
 {
     NativeRect rect = new NativeRect();
     if (!GetClientRect(hwnd, ref rect))
     {
         size = new System.Drawing.Size(-1, -1);
         return false;
     }
     size = new System.Drawing.Size(rect.Right, rect.Bottom);
     return true;
 }
        internal static System.Drawing.Size GetNonClientArea(IntPtr hwnd)
        {
            var c = new NativePoint();

            TabbedThumbnailNativeMethods.ClientToScreen(hwnd, ref c);

            var r = new NativeRect();

            TabbedThumbnailNativeMethods.GetWindowRect(hwnd, ref r);

            return new System.Drawing.Size(c.X - r.Left, c.Y - r.Top);
        }
 internal static extern bool GetClientRect(IntPtr hwnd, ref NativeRect rect);
 internal static extern bool GetWindowRect(IntPtr hwnd, ref NativeRect rect);
        /// <summary>
        /// Selects a portion of a window's client area to display as that window's thumbnail in the taskbar.
        /// </summary>
        /// <param name="windowHandle">The handle to a window represented in the taskbar. This has to be a top-level window.</param>
        /// <param name="clippingRectangle">Rectangle structure that specifies a selection within the window's client area,
        /// relative to the upper-left corner of that client area.
        /// <para>If this parameter is null, the clipping area will be cleared and the default display of the thumbnail will be used instead.</para></param>
        public void SetThumbnailClip(IntPtr windowHandle, Rectangle? clippingRectangle)
        {
            if (clippingRectangle == null)
            {
                ClearThumbnailClip(windowHandle);
                return;
            }

            NativeRect rect = new NativeRect();
            rect.Left = clippingRectangle.Value.Left;
            rect.Top = clippingRectangle.Value.Top;
            rect.Right = clippingRectangle.Value.Right;
            rect.Bottom = clippingRectangle.Value.Bottom;

            IntPtr rectPtr = Marshal.AllocCoTaskMem(Marshal.SizeOf(rect));
            try
            {
                Marshal.StructureToPtr(rect, rectPtr, true);
                TaskbarList.Instance.SetThumbnailClip(windowHandle, rectPtr);
            }
            finally
            {
                Marshal.FreeCoTaskMem(rectPtr);
            }
        }
 public virtual extern void SetRect([In, Out] ref IntPtr phdwp, NativeRect rcBrowser);