AGS.Editor.Utilities.GetControlThatHasFocus C# (CSharp) Method

GetControlThatHasFocus() public static method

public static GetControlThatHasFocus ( ) : Control
return System.Windows.Forms.Control
        public static Control GetControlThatHasFocus()
        {
            Control focusControl = null;
            IntPtr focusHandle = GetFocus();
            if (focusHandle != IntPtr.Zero)
            {
                // returns null if handle is not to a .NET control
                focusControl = Control.FromHandle(focusHandle);
            }
            return focusControl;
        }

Usage Example

Example #1
0
        private bool DoesThisPanelHaveFocus()
        {
            Control focused = Utilities.GetControlThatHasFocus();

            return(focused == this.ActiveControl);
        }