[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.Winapi)] internal static extern IntPtr GetFocus(); ///獲取 當前擁有焦點 ...
[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