Beispiel #1
0
        private void InitializeThumbnail()
        {
            if (IntPtr.Zero != _thumb)
            {
                // release the old thumbnail
                ReleaseThumbnail();
            }

            if (IntPtr.Zero == Handle)
            {
                return;
            }

            // find our parent hwnd
            _target = (HwndSource)HwndSource.FromVisual(this);

            // if we have one, we can attempt to register the thumbnail
            if (_target == null || 0 != DwmUtils.DwmRegisterThumbnail(_target.Handle, Handle, out this._thumb))
            {
                return;
            }

            DwmThumbnailProperties props = new DwmThumbnailProperties();

            props.Visible = false;
            props.SourceClientAreaOnly = false;
            props.Opacity = (byte)(255 * this.Opacity);
            props.Flags   = ThumbnailFlags.Visible |
                            ThumbnailFlags.SourceClientAreaOnly |
                            ThumbnailFlags.Opacity;

            DwmUtils.DwmUpdateThumbnailProperties(_thumb, ref props);
        }
Beispiel #2
0
        private void InitialiseThumbnail(IntPtr source)
        {
            if (IntPtr.Zero != thumb)
            {
                // release the old thumbnail
                ReleaseThumbnail();
            }

            if (IntPtr.Zero != source)
            {
                // find our parent hwnd
                target = (HwndSource)HwndSource.FromVisual(this);

                // if we have one, we can attempt to register the thumbnail
                if (target != null && 0 == DwmUtils.DwmRegisterThumbnail(target.Handle, source, out this.thumb))
                {
                    DwmThumbnailProperties props = new DwmThumbnailProperties();
                    props.Visible = false;
                    props.SourceClientAreaOnly = this.ClientAreaOnly;
                    props.Opacity = (byte)(255 * this.Opacity);
                    props.Flags   = ThumbnailFlags.Visible | ThumbnailFlags.SourceClientAreaOnly
                                    | ThumbnailFlags.Opacity;
                    DwmUtils.DwmUpdateThumbnailProperties(thumb, ref props);
                }
            }
        }