Example #1
0
        /// <summary>Registers a thumbnail to be drawn on a window.</summary>
        /// <remarks>The thumbnail will not be drawn until you update the thumbnail's properties calling Update().</remarks>
        /// <param name="destination">The handle (HWND) of the window on which the thumbnail will be drawn.</param>
        /// <param name="source">The handle (HWND) of the window that has to be drawn.</param>
        /// <returns>A Thumbnail instance, needed to unregister and to update properties.</returns>
        public static Thumbnail Register(IntPtr destination, IntPtr source) {
            if (!OsSupport.IsVistaOrBetter)
                throw new DwmCompositionException(Resources.ExceptionMessages.DWMOsNotSupported);

            if (!OsSupport.IsCompositionEnabled)
                throw new DwmCompositionException(Resources.ExceptionMessages.DWMNotEnabled);

            if (destination == source)
                throw new DwmCompositionException(Resources.ExceptionMessages.DWMWindowMatch);

            Thumbnail ret = new Thumbnail();
            if (NativeMethods.DwmRegisterThumbnail(destination, source, out ret) == 0) {
                return ret;
            }
            else {
                throw new DwmCompositionException(String.Format(Resources.ExceptionMessages.NativeCallFailure, "DwmRegisterThumbnail"));
            }
        }
Example #2
0
 public static extern int DwmQueryThumbnailSourceSize(Thumbnail hThumbnail, out DwmSize pSize);
Example #3
0
 public static extern int DwmUpdateThumbnailProperties(Thumbnail hThumbnailId, ref DwmThumbnailProperties ptnProperties);
Example #4
0
 public static extern int DwmRegisterThumbnail(IntPtr hwndDestination, IntPtr hwndSource, out Thumbnail phThumbnailId);
Example #5
0
        private void RecomputeParentForm()
        {
            //Get the owning form
            Form nextParent = this.TopLevelControl as Form;

            if (nextParent == null) {
                //No owning form found (!)
                _topLevelForm = null;
                if (_thumbnail != null) {
                    _thumbnail.Dispose();
                    _thumbnail = null;
                }
                return;
            }

            if (_thumbnail != null && _topLevelForm != nextParent) {
                //Parent changed from last time
                _thumbnail.Dispose();
                _thumbnail = null;
            }

            _topLevelForm = nextParent;
        }
Example #6
0
 void originForm_FormClosed(object sender, FormClosedEventArgs e)
 {
     if (_thumbnail != null) {
         _thumbnail.Dispose();
         _thumbnail = null;
     }
 }
Example #7
0
        public void SetThumbnail(IntPtr originHandle)
        {
            RecomputeParentForm();

            if (_topLevelForm != null) {
                _thumbnail = DwmManager.Register(_topLevelForm, originHandle);
                UpdateThumbnail(Visible);
            }
            else
                throw new Exception("Control must have an owner.");
        }
Example #8
0
 public static void Unregister(Thumbnail handle) {
     if (handle != null) {
         handle.Close();
     }
 }
Example #9
0
 public static extern int DwmUpdateThumbnailProperties(Thumbnail hThumbnailId, ref DwmThumbnailProperties ptnProperties);
Example #10
0
 public static extern int DwmRegisterThumbnail(IntPtr hwndDestination, IntPtr hwndSource, out Thumbnail phThumbnailId);
Example #11
0
 public static extern int DwmQueryThumbnailSourceSize(Thumbnail hThumbnail, out DwmSize pSize);