/// <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
_obscurer?.Uncover();
}
base.WndProc(ref m);
}