Esempio n. 1
0
        /// <summary>
        /// Sets the specified peek (live preview) bitmap for the specified
        /// window.  This is typically done in response to a DWM message.
        /// </summary>
        /// <param name="hwnd">The window handle.</param>
        /// <param name="bitmap">The thumbnail bitmap.</param>
        /// <param name="offset">The client area offset at which to display
        /// the specified bitmap.  The rest of the parent window will be
        /// displayed as "remembered" by the DWM.</param>
        /// <param name="displayFrame">Whether to display a standard window
        /// frame around the bitmap.</param>
        internal static void SetPeekBitmap(IntPtr hwnd, IntPtr bitmap, Point offset, bool displayFrame)
        {
            var nativePoint = new CoreNativeMethods.POINT(offset.X, offset.Y);
            int rc          = DwmSetIconicLivePreviewBitmap(
                hwnd,
                bitmap,
                ref nativePoint,
                displayFrame ? DWM_SIT_DISPLAYFRAME : (uint)0);

            if (rc != 0)
            {
                Exception e = Marshal.GetExceptionForHR(rc);

                if (e is ArgumentException)
                {
                    // Ignore argument exception as it's not really recommended to be throwing
                    // exception when rendering the peek bitmap. If it's some other kind of exception,
                    // then throw it.
                }
                else
                {
                    throw e;
                }
            }
        }
Esempio n. 2
0
        internal static System.Drawing.Size GetNonClientArea(IntPtr hwnd)
        {
            var c = new CoreNativeMethods.POINT(0, 0);

            TabbedThumbnailNativeMethods.ClientToScreen(hwnd, ref c);

            var r = new CoreNativeMethods.RECT();

            TabbedThumbnailNativeMethods.GetWindowRect(hwnd, ref r);

            return(new System.Drawing.Size(c.X - r.left, c.Y - r.top));
        }
Esempio n. 3
0
        internal static System.Drawing.Point GetParentOffsetOfChild(IntPtr hwnd, IntPtr hwndParent)
        {
            var childScreenCoord = new CoreNativeMethods.POINT(0, 0);

            TabbedThumbnailNativeMethods.ClientToScreen(
                hwnd, ref childScreenCoord);

            var parentScreenCoord = new CoreNativeMethods.POINT(0, 0);

            TabbedThumbnailNativeMethods.ClientToScreen(
                hwndParent, ref parentScreenCoord);

            System.Drawing.Point offset = new System.Drawing.Point(
                childScreenCoord.X - parentScreenCoord.X,
                childScreenCoord.Y - parentScreenCoord.Y);

            return(offset);
        }
Esempio n. 4
0
 internal static extern int DwmSetIconicLivePreviewBitmap(
     IntPtr hwnd,
     IntPtr hbitmap,
     ref CoreNativeMethods.POINT ptClient,
     uint flags);
Esempio n. 5
0
 internal static extern bool ClientToScreen(
     IntPtr hwnd,
     ref CoreNativeMethods.POINT point);