| 99 | } |
| 100 | |
| 101 | std::optional<std::wstring> Window::classname() const |
| 102 | { |
| 103 | std::wstring className; |
| 104 | bool failed = false; |
| 105 | // https://learn.microsoft.com/en-us/windows/win32/api/winuser/ns-winuser-wndclassw |
| 106 | // The maximum length for lpszClassName is 256. |
| 107 | className.resize_and_overwrite(256, [hwnd = m_WindowHandle, &failed](wchar_t* data, std::size_t count) |
| 108 | { |
| 109 | const int length = GetClassName(hwnd, data, static_cast<int>(count) + 1); |
| 110 | if (!length) |
| 111 | { |
| 112 | LastErrorHandle(spdlog::level::info, L"Getting class name of a window failed."); |
| 113 | failed = true; |
| 114 | } |
| 115 | |
| 116 | return length; |
| 117 | }); |
| 118 | |
| 119 | if (!failed) |
| 120 | { |
| 121 | return { std::move(className) }; |
| 122 | } |
| 123 | else |
| 124 | { |
| 125 | return std::nullopt; |
| 126 | } |
| 127 | } |
| 128 | |
| 129 | std::optional<std::filesystem::path> Window::file() const |
| 130 | { |
no outgoing calls
no test coverage detected