S. Ganesh | 42998b0 | 2023-09-14 20:18:43 | [diff] [blame] | 1 | // Copyright 2023 The Chromium Authors |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef BASE_WIN_WINDOW_ENUMERATOR_H_ |
| 6 | #define BASE_WIN_WINDOW_ENUMERATOR_H_ |
| 7 | |
S. Ganesh | 42998b0 | 2023-09-14 20:18:43 | [diff] [blame] | 8 | #include <string> |
| 9 | |
| 10 | #include "base/base_export.h" |
| 11 | #include "base/functional/callback.h" |
Greg Thompson | 75b1a06 | 2023-09-18 00:08:36 | [diff] [blame] | 12 | #include "base/win/windows_types.h" |
S. Ganesh | 42998b0 | 2023-09-14 20:18:43 | [diff] [blame] | 13 | |
| 14 | namespace base::win { |
| 15 | |
Greg Thompson | 75b1a06 | 2023-09-18 00:08:36 | [diff] [blame] | 16 | // Enumerates immediate child windows of `parent`, running `filter` for each |
| 17 | // window until `filter` returns true. |
| 18 | using WindowEnumeratorCallback = base::RepeatingCallback<bool(HWND hwnd)>; |
| 19 | BASE_EXPORT void EnumerateChildWindows(HWND parent, |
| 20 | WindowEnumeratorCallback filter); |
S. Ganesh | 42998b0 | 2023-09-14 20:18:43 | [diff] [blame] | 21 | |
Greg Thompson | 75b1a06 | 2023-09-18 00:08:36 | [diff] [blame] | 22 | // Returns true if `hwnd` is an always-on-top window. |
| 23 | BASE_EXPORT bool IsTopmostWindow(HWND hwnd); |
S. Ganesh | 42998b0 | 2023-09-14 20:18:43 | [diff] [blame] | 24 | |
Greg Thompson | 75b1a06 | 2023-09-18 00:08:36 | [diff] [blame] | 25 | // Returns true if `hwnd` is a system dialog. |
| 26 | BASE_EXPORT bool IsSystemDialog(HWND hwnd); |
S. Ganesh | 42998b0 | 2023-09-14 20:18:43 | [diff] [blame] | 27 | |
Greg Thompson | 75b1a06 | 2023-09-18 00:08:36 | [diff] [blame] | 28 | // Returns true if `hwnd` is a window owned by the Windows shell. |
| 29 | BASE_EXPORT bool IsShellWindow(HWND hwnd); |
S. Ganesh | 42998b0 | 2023-09-14 20:18:43 | [diff] [blame] | 30 | |
Greg Thompson | 75b1a06 | 2023-09-18 00:08:36 | [diff] [blame] | 31 | // Returns the class name of `hwnd` or an empty string on error. |
| 32 | BASE_EXPORT std::wstring GetWindowClass(HWND hwnd); |
S. Ganesh | 42998b0 | 2023-09-14 20:18:43 | [diff] [blame] | 33 | |
Greg Thompson | 75b1a06 | 2023-09-18 00:08:36 | [diff] [blame] | 34 | // Returns the window text for `hwnd`, or an empty string on error. |
| 35 | BASE_EXPORT std::wstring GetWindowTextString(HWND hwnd); |
S. Ganesh | 42998b0 | 2023-09-14 20:18:43 | [diff] [blame] | 36 | |
| 37 | } // namespace base::win |
| 38 | |
| 39 | #endif // BASE_WIN_WINDOW_ENUMERATOR_H_ |