| 11 | class Window; |
| 12 | |
| 13 | class WindowClass { |
| 14 | private: |
| 15 | ATOM m_Atom; |
| 16 | HINSTANCE m_hInstance; |
| 17 | wil::unique_hicon m_hIconSmall, m_hIcon; |
| 18 | wil::srwlock m_Lock; |
| 19 | |
| 20 | void LoadIcons(const wchar_t *iconResource); |
| 21 | void Unregister(); |
| 22 | |
| 23 | public: |
| 24 | WindowClass(WNDPROC procedure, Util::null_terminated_wstring_view className, const wchar_t *iconResource, HINSTANCE hInstance, unsigned int style = 0, HBRUSH brush = nullptr, HCURSOR cursor = LoadCursor(nullptr, IDC_ARROW)); |
| 25 | |
| 26 | inline LPCWSTR atom() const noexcept { return reinterpret_cast<LPCWSTR>(static_cast<INT_PTR>(m_Atom)); } |
| 27 | inline HINSTANCE hinstance() const noexcept { return m_hInstance; } |
| 28 | |
| 29 | void ChangeIcon(Window window, const wchar_t *iconResource); |
| 30 | |
| 31 | inline WindowClass(const WindowClass &) = delete; |
| 32 | inline WindowClass &operator =(const WindowClass &) = delete; |
| 33 | |
| 34 | // NOTE: these operators can only be used BEFORE making a window. |
| 35 | // once a window is made, and as long as it's alive, the WindowClass |
| 36 | // can't move. |
| 37 | inline WindowClass(WindowClass &&other) noexcept : |
| 38 | m_Atom(std::exchange(other.m_Atom, static_cast<ATOM>(0))), |
| 39 | m_hInstance(std::exchange(other.m_hInstance, nullptr)), |
| 40 | m_hIconSmall(std::move(other.m_hIconSmall)), |
| 41 | m_hIcon(std::move(other.m_hIcon)) |
| 42 | { } |
| 43 | |
| 44 | inline WindowClass& operator =(WindowClass&& other) noexcept |
| 45 | { |
| 46 | if (this != &other) |
| 47 | { |
| 48 | std::swap(m_Atom, other.m_Atom); |
| 49 | std::swap(m_hInstance, other.m_hInstance); |
| 50 | std::swap(m_hIconSmall, other.m_hIconSmall); |
| 51 | std::swap(m_hIcon, other.m_hIcon); |
| 52 | } |
| 53 | |
| 54 | return *this; |
| 55 | } |
| 56 | |
| 57 | inline ~WindowClass() |
| 58 | { |
| 59 | if (m_Atom != 0) |
| 60 | { |
| 61 | Unregister(); |
| 62 | } |
| 63 | } |
| 64 | }; |
nothing calls this directly
no outgoing calls
no test coverage detected