Sowl  1.0
Simple Object Window Library
Window.h
1 #pragma once
2 #include <Windows.h>
3 #include <type_traits>
4 
5 namespace sowl
6 {
8  class Window
9  {
10  public:
11  // create
12  Window();
13  explicit Window(HWND hwnd);
14  Window(const Window& other) = delete; // avoid copy constructor
15  Window(Window&& other) noexcept; // control move constructor
16 
17  // destroy
18  ~Window();
19  void Destroy();
20 
21  // assignment operator overloads
22  Window& operator=(const Window& other) = delete; // avoid copy assignment
23  Window& operator=(Window&& other) noexcept; // control move assignment
24 
25  protected:
26  void SetHandle(HWND handle);
27  void UnsetHandle();
28 
29  public:
30  // other methods
31  HWND GetHandle() const;
32  HINSTANCE GetProcessHandle() const;
33  HWND GetDialogItem(int id) const;
34  bool Show(int nCmdShow) const;
35  void Enable(bool enable);
36  bool IsEnabled();
37  void SetClassCursor(HCURSOR hcursor);
38  void SetText(LPCWSTR title);
39  bool InvalidateRect(bool erase);
40  bool InvalidateRect(const RECT& rect, bool erase);
41  RECT GetClientRect();
42 
43  private:
44  HWND hwnd;
45  };
46 }
RECT GetClientRect()
Encapsulates a call to GetClientRect.
Definition: Window.cpp:132
bool InvalidateRect(bool erase)
Encapsulates a call to InvalidateRect with lpRect to NULL.
Definition: Window.cpp:116
void Enable(bool enable)
Encapsulates a call to EnableWindow.
Definition: Window.cpp:87
bool Show(int nCmdShow) const
Encapsulates a call to ShowWindow.
Definition: Window.cpp:142
HWND GetDialogItem(int id) const
Encapsulates a call to GetDlgItem.
Definition: Window.cpp:80
HINSTANCE GetProcessHandle() const
Get the process handle (HINSTANCE) where the encapsulated handle window belongs to...
Definition: Window.cpp:72
bool IsEnabled()
Encapsulates a call to IsWindowEnabled.
Definition: Window.cpp:94
void UnsetHandle()
Unset the window-handle. This method is expected to be called inside a window-message-processing fun...
Definition: Window.cpp:60
void SetHandle(HWND handle)
Set a window-handle to an expected unsetted Window object. If the Window object was already set...
Definition: Window.cpp:49
void Destroy()
Release the encapsulated HWND if it is valid.
Definition: Window.cpp:29
void SetClassCursor(HCURSOR hcursor)
Encapsulates a call to SetClassLong with index GCL_HCURSOR.
Definition: Window.cpp:101
~Window()
Call Destroy().
Definition: Window.cpp:23
void SetText(LPCWSTR title)
Encapsulates a call to SetWindowText.
Definition: Window.cpp:108
Encapsulates a window handle.
Definition: Window.h:8