winfrom 獲取焦點控件

[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/7402307api

相關文章
相關標籤/搜索