protected override void WndProc(ref Message m)
{
if (IsDisposed)
return;
if (m.Msg == s_wm_kmselectlang)
{
IntPtr focusWnd = Win32.GetFocus();
if (focusWnd != IntPtr.Zero)
{
Win32.SendMessage(focusWnd, m.Msg, m.WParam, m.LParam);
focusWnd = IntPtr.Zero;
return; // No need to pass it on to the superclass, since we dealt with it.
}
}
base.WndProc (ref m);
// In Mono, closing a dialog invokes WM_ACTIVATE on the active form, which then selects
// its active control. This swallows keyboard input. To prevent this, we select the
// desired control if one has been established so that keyboard input can still be seen
// by that control. (See FWNX-785.)
if (MiscUtils.IsMono && m.Msg == (int)Win32.WinMsgs.WM_ACTIVATE && m.HWnd == this.Handle &&
DesiredControl != null && !DesiredControl.IsDisposed && DesiredControl.Visible && DesiredControl.Enabled)
{
DesiredControl.Select();
}
}