/// <summary>
 /// Enables custom thumbnails for the form
 /// </summary>
 /// <param name="e">The arguments for this event</param>
 protected override void OnLoad(EventArgs e)
 {
     if (!DesignMode)
     {
         TabbedThumbnailNativeMethods.EnableCustomWindowPreview(Handle, true);
     }
     base.OnLoad(e);
 }
Пример #2
0
        public 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));
        }
Пример #3
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));
        }
Пример #4
0
        public static System.Drawing.Point GetParentOffsetOfChild(IntPtr hwnd, IntPtr hwndParent)
        {
            var childScreenCoord = new NativePoint();

            TabbedThumbnailNativeMethods.ClientToScreen(hwnd, ref childScreenCoord);

            var parentScreenCoord = new NativePoint();

            TabbedThumbnailNativeMethods.ClientToScreen(hwndParent, ref parentScreenCoord);

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

            return(offset);
        }
        /// <summary>
        /// Handles taskbar-related messages
        /// </summary>
        /// <param name="m">A message</param>
        protected override void WndProc(ref System.Windows.Forms.Message m)
        {
            if (m.Msg == (int)TaskbarNativeMethods.WM_DWMSENDICONICTHUMBNAIL)
            {
                int  width         = (int)((long)m.LParam >> 16);
                int  height        = (int)(((long)m.LParam) & (0xFFFF));
                Size requestedSize = new Size(width, height);
                using (Bitmap iconicThumb = GetIconicThumbnail(requestedSize)) {
                    TabbedThumbnailNativeMethods.SetIconicThumbnail(Handle, iconicThumb.GetHbitmap());
                }
            }
            else if (m.Msg == (int)TaskbarNativeMethods.WM_DWMSENDICONICLIVEPREVIEWBITMAP)
            {
                using (Bitmap peekBitmap = GetPeekBitmap()) {
                    TabbedThumbnailNativeMethods.SetPeekBitmap(Handle, peekBitmap.GetHbitmap(), false);
                }
            }

            base.WndProc(ref m);
        }
 /// <summary>
 /// Invalidates the thumbnails
 /// </summary>
 protected void InvalidateThumbnails()
 {
     TabbedThumbnailNativeMethods.DwmInvalidateIconicBitmaps(Handle);
 }