internal void FocusActiveControlInternal() { if (active_control != null && active_control.Visible) { // Avoid focus loops, especially with ComboBoxes, on Win98/ME. IntPtr focusHandle = XplatUI.GetFocus(); if (focusHandle == IntPtr.Zero || Control.FromChildHandle(focusHandle) != active_control) { XplatUI.SetFocus(active_control.Handle); } } else { // Determine and focus closest visible parent ContainerControl cc = this; while (cc != null && !cc.Visible) { Control parent = cc.Parent; if (parent != null) { cc = parent.GetContainerControl() as ContainerControl; } else { break; } } if (cc != null && cc.Visible) { XplatUI.SetFocus(cc.Handle); } } }
private bool FocusInside() { if (!IsHandleCreated) { return(false); } IntPtr hwndFocus = XplatUI.GetFocus(); if (hwndFocus == IntPtr.Zero) { return(false); } IntPtr hwnd = Handle; if (hwnd == hwndFocus || IsChild(hwnd, hwndFocus)) { return(true); } return(false); }