diff --git a/SunnyUI/Common/USystem.cs b/SunnyUI/Common/USystem.cs index a185e53a..a55be8b3 100644 --- a/SunnyUI/Common/USystem.cs +++ b/SunnyUI/Common/USystem.cs @@ -27,6 +27,7 @@ using System.Drawing; using System.IO; using System.Linq; using System.Reflection; +using System.Threading; using System.Windows.Forms; namespace Sunny.UI @@ -131,9 +132,19 @@ namespace Sunny.UI /// Delays the specified ms. /// /// The ms. - 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); + } } /// diff --git a/SunnyUI/Controls/UITabControl.cs b/SunnyUI/Controls/UITabControl.cs index 418756ad..cb7e1397 100644 --- a/SunnyUI/Controls/UITabControl.cs +++ b/SunnyUI/Controls/UITabControl.cs @@ -27,6 +27,7 @@ * 2022-01-13: V3.1.0 修改删除页面时的页面跳转 * 2022-04-18: V3.1.5 关闭按钮增加鼠标移入的效果 * 2022-04-20: V3.1.5 不显示标签页时屏蔽左右键 + * 2022-05-11: V3.1.8 修复屏蔽左右键后其他控件无法使用左右键的问题 ******************************************************************************/ 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) - { - if (!TabVisible) - { - if (e.KeyCode == Keys.Left || e.KeyCode == Keys.Right) - { - e.Handled = true; - } - else - { - base.OnKeyDown(e); - } - } - else - { - base.OnKeyDown(e); - } + return base.ProcessCmdKey(ref msg, keyData); } [DefaultValue(true)]