/// <summary> /// Process Windows-based messages. /// </summary> /// <param name="m">A Windows-based message.</param> protected override void WndProc(ref Message m) { if (m.Msg == PI.WM_WINDOWPOSCHANGING) { // First time around we need to create the obscurer if (_obscurer == null) { _obscurer = new ScreenObscurer(); } // Obscure the display area of the control if (!IsDisposed && IsHandleCreated && !DesignMode) { _obscurer.Cover(this); } // Just in case the WM_WINDOWPOSCHANGED does not occur we can // ensure the obscurer is removed using this async delegate call BeginInvoke(_removeObscurer); } if (m.Msg == PI.WM_WINDOWPOSCHANGED) { // Uncover from the covered area if (_obscurer != null) { _obscurer.Uncover(); } } base.WndProc(ref m); }
/// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) { if (disposing) { // Remove any cached obscurer if (_obscurer != null) { try { _obscurer.Uncover(); _obscurer.Dispose(); _obscurer = null; } catch { } } } base.Dispose(disposing); }