コード例 #1
0
ファイル: DwmThumbnail.cs プロジェクト: fuheinv/eve-o-preview
        public void Register(IntPtr destination, IntPtr source)
        {
            this._properties         = new DWM_THUMBNAIL_PROPERTIES();
            this._properties.dwFlags = DWM_TNP_CONSTANTS.DWM_TNP_VISIBLE
                                       + DWM_TNP_CONSTANTS.DWM_TNP_OPACITY
                                       + DWM_TNP_CONSTANTS.DWM_TNP_RECTDESTINATION
                                       + DWM_TNP_CONSTANTS.DWM_TNP_SOURCECLIENTAREAONLY;
            this._properties.opacity  = 255;
            this._properties.fVisible = true;
            this._properties.fSourceClientAreaOnly = true;

            if (!this._windowManager.IsCompositionEnabled)
            {
                return;
            }

            try
            {
                this._handle = DwmNativeMethods.DwmRegisterThumbnail(destination, source);
            }
            catch (ArgumentException)
            {
                // This exception is raised if the source client is already closed
                // Can happen on a really slow CPU's that the window is still being
                // listed in the process list yet it already cannot be used as
                // a thumbnail source
                this._handle = IntPtr.Zero;
            }
            catch (COMException)
            {
                // This exception is raised if DWM is suddenly not available
                // (f.e. when switching between Windows user accounts)
                this._handle = IntPtr.Zero;
            }
        }
コード例 #2
0
 public WindowManager()
 {
     // Composition is always enabled for Windows 8+
     this.IsCompositionEnabled =
         ((Environment.OSVersion.Version.Major == 6) && (Environment.OSVersion.Version.Minor >= 2)) ||              // Win 8 and Win 8.1
         (Environment.OSVersion.Version.Major >= 10) ||                 // Win 10
         DwmNativeMethods.DwmIsCompositionEnabled();                    // In case of Win 7 an API call is requiredWin 7
 }
コード例 #3
0
        public void HideFromPeek(IWindowWithHandle window)
        {
            var handle = window.RetrieveHandle();

            var attrValue = (int)DwmRenderingPolicy.Enabled;

            DwmNativeMethods.DwmSetWindowAttribute(handle, DwmWindowAttribute.ExcludedFromPeek, ref attrValue, sizeof(int));

            DwmNativeMethods.DwmSetWindowAttribute(handle, DwmWindowAttribute.DisallowPeek, ref attrValue, sizeof(int));
        }
コード例 #4
0
ファイル: DwmThumbnail.cs プロジェクト: fuheinv/eve-o-preview
        public void Unregister()
        {
            if ((!this._windowManager.IsCompositionEnabled) || (this._handle == IntPtr.Zero))
            {
                return;
            }

            try
            {
                DwmNativeMethods.DwmUnregisterThumbnail(this._handle);
            }
            catch (ArgumentException)
            {
            }
            catch (COMException)
            {
                // This exception is raised when DWM is not available for some reason
            }
        }
コード例 #5
0
ファイル: DwmThumbnail.cs プロジェクト: fuheinv/eve-o-preview
        public void Update()
        {
            if ((!this._windowManager.IsCompositionEnabled) || (this._handle == IntPtr.Zero))
            {
                return;
            }

            try
            {
                DwmNativeMethods.DwmUpdateThumbnailProperties(this._handle, this._properties);
            }
            catch (ArgumentException)
            {
                // This exception will be thrown if the EVE client disappears while this method is running
            }
            catch (COMException)
            {
                // This exception is raised when DWM is not available for some reason
            }
        }