private void UpdateThumb() { if (Thumb != IntPtr.Zero) { DwmQueryThumbnailSourceSize(Thumb, out PSIZE size); DWM_THUMBNAIL_PROPERTIES props = new DWM_THUMBNAIL_PROPERTIES { fVisible = true, dwFlags = DWM_TNP_VISIBLE | DWM_TNP_RECTDESTINATION | DWM_TNP_OPACITY, //opacity = (byte)opacity.Value, opacity = 255, rcDestination = new Rect(ThumbnailControl.Left, ThumbnailControl.Top, ThumbnailControl.Right, ThumbnailControl.Bottom) }; if (size.x < ThumbnailControl.Width) { props.rcDestination.Right = props.rcDestination.Left + size.x; } if (size.y < ThumbnailControl.Height) { props.rcDestination.Bottom = props.rcDestination.Top + size.y; } DwmUpdateThumbnailProperties(Thumb, ref props); } }
static extern int DwmUpdateThumbnailProperties(IntPtr hThumb, ref DWM_THUMBNAIL_PROPERTIES props);