[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.Winapi)]
        internal static extern IntPtr GetFocus();
        ///获取 当前拥有焦点的控件
        private Control GetFocusedControl()
        {
            Control focusedControl = null;
            IntPtr focusedHandle = GetFocus();
            if (focusedHandle != IntPtr.Zero)
            focusedControl = Control.FromChildHandle(focusedHandle);
            return focusedControl;
        }
View Code

原文连接:https://blog.csdn.net/alisa525/article/details/7402307

 

posted on 2019-11-07 16:56  AnonymousFlower  阅读(431)  评论(0编辑  收藏  举报