Exemplo n.º 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"));
            }
        }
Exemplo n.º 2
0
 public static extern int DwmQueryThumbnailSourceSize(Thumbnail hThumbnail, out DwmSize pSize);
Exemplo n.º 3
0
 public static extern int DwmUpdateThumbnailProperties(Thumbnail hThumbnailId, ref DwmThumbnailProperties ptnProperties);
Exemplo n.º 4
0
 public static extern int DwmRegisterThumbnail(IntPtr hwndDestination, IntPtr hwndSource, out Thumbnail phThumbnailId);
Exemplo n.º 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;
        }
Exemplo n.º 6
0
 void originForm_FormClosed(object sender, FormClosedEventArgs e)
 {
     if (_thumbnail != null) {
         _thumbnail.Dispose();
         _thumbnail = null;
     }
 }
Exemplo n.º 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.");
        }
Exemplo n.º 8
0
 public static void Unregister(Thumbnail handle) {
     if (handle != null) {
         handle.Close();
     }
 }
Exemplo n.º 9
0
 public static extern int DwmUpdateThumbnailProperties(Thumbnail hThumbnailId, ref DwmThumbnailProperties ptnProperties);
Exemplo n.º 10
0
 public static extern int DwmRegisterThumbnail(IntPtr hwndDestination, IntPtr hwndSource, out Thumbnail phThumbnailId);
Exemplo n.º 11
0
 public static extern int DwmQueryThumbnailSourceSize(Thumbnail hThumbnail, out DwmSize pSize);