public void Update() { if (_thumbHandle == IntPtr.Zero) { return; } DWMApi.DwmQueryThumbnailSourceSize(_thumbHandle, out PSIZE size); var props = new DWM_THUMBNAIL_PROPERTIES { fVisible = true, dwFlags = DWMApi.DWM_TNP_VISIBLE | DWMApi.DWM_TNP_RECTDESTINATION | DWMApi.DWM_TNP_OPACITY, opacity = 255, rcDestination = _targetRect }; if (size.x < _targetRect.Width) { props.rcDestination.Right = props.rcDestination.Left + size.x; } if (size.y < _targetRect.Height) { props.rcDestination.Bottom = props.rcDestination.Top + size.y; } DWMApi.DwmUpdateThumbnailProperties(_thumbHandle, ref props); }
public static extern int DwmUpdateThumbnailProperties(IntPtr hThumb, ref DWM_THUMBNAIL_PROPERTIES props);