public bool EnumChildren(IntPtr hwnd, IntPtr lParam) { int level = 1; if (WindowNative.IsWindowVisible(hwnd) && ModalWindowUtils.IsOwned(lParam, hwnd, ref level) && level > _maxOwnershipLevel) { MaxOwnershipHandle = hwnd; _maxOwnershipLevel = level; } return(true); }