* UITabControl: 修复屏蔽左右键后其他控件无法使用左右键的问题

This commit is contained in:
Sunny 2022-05-11 19:36:04 +08:00
parent f87e366b57
commit 5a22a14fc5
2 changed files with 27 additions and 21 deletions

View File

@ -27,6 +27,7 @@ using System.Drawing;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Threading;
using System.Windows.Forms; using System.Windows.Forms;
namespace Sunny.UI namespace Sunny.UI
@ -131,9 +132,19 @@ namespace Sunny.UI
/// Delays the specified ms. /// Delays the specified ms.
/// </summary> /// </summary>
/// <param name="ms">The ms.</param> /// <param name="ms">The ms.</param>
public static void Delay(int ms) public static void Sleep(int ms)
{ {
System.Threading.Thread.Sleep(Math.Max(0, ms)); var sw = Stopwatch.StartNew();
var sleepMs = ms - 16;
if (sleepMs > 0)
{
Thread.Sleep(sleepMs);
}
while (sw.ElapsedMilliseconds < ms)
{
Thread.Sleep(0);
}
} }
/// <summary> /// <summary>

View File

@ -27,6 +27,7 @@
* 2022-01-13: V3.1.0 * 2022-01-13: V3.1.0
* 2022-04-18: V3.1.5 * 2022-04-18: V3.1.5
* 2022-04-20: V3.1.5 * 2022-04-20: V3.1.5
* 2022-05-11: V3.1.8 使
******************************************************************************/ ******************************************************************************/
using Sunny.UI.Win32; using Sunny.UI.Win32;
@ -198,26 +199,20 @@ namespace Sunny.UI
} }
} }
return base.ProcessCmdKey(ref msg, keyData); if (Focused && !TabVisible)
} {
switch (keyData)
{
case Keys.Left:
//if (TabVisible)
return true;
case Keys.Right:
//if (TabVisible)
return true;
}
}
protected override void OnKeyDown(KeyEventArgs e) return base.ProcessCmdKey(ref msg, keyData);
{
if (!TabVisible)
{
if (e.KeyCode == Keys.Left || e.KeyCode == Keys.Right)
{
e.Handled = true;
}
else
{
base.OnKeyDown(e);
}
}
else
{
base.OnKeyDown(e);
}
} }
[DefaultValue(true)] [DefaultValue(true)]