diff options
author | 杨宇千 <crupest@outlook.com> | 2019-03-28 20:39:36 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-28 20:39:36 +0800 |
commit | c45a6e62298e972f5945f5f3461ed723aea80317 (patch) | |
tree | f46ef303ee87a8e3814ea8743bd7062d432bfee3 /src/ui/window_class.cpp | |
parent | b028e74a48de181ca078ad3bf4ababf4fa146cd3 (diff) | |
parent | 37216f211b0e22205a3a0d3373d985fc68aea59b (diff) | |
download | cru-c45a6e62298e972f5945f5f3461ed723aea80317.tar.gz cru-c45a6e62298e972f5945f5f3461ed723aea80317.tar.bz2 cru-c45a6e62298e972f5945f5f3461ed723aea80317.zip |
Merge pull request #37 from crupest/render
Refactor.
Diffstat (limited to 'src/ui/window_class.cpp')
-rw-r--r-- | src/ui/window_class.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/ui/window_class.cpp b/src/ui/window_class.cpp new file mode 100644 index 00000000..5e8b3454 --- /dev/null +++ b/src/ui/window_class.cpp @@ -0,0 +1,28 @@ +#include "window_class.hpp" + +#include "exception.hpp" + +namespace cru::ui { +WindowClass::WindowClass(const String& name, WNDPROC window_proc, + HINSTANCE h_instance) + : name_(name) { + WNDCLASSEX window_class; + window_class.cbSize = sizeof(WNDCLASSEX); + + window_class.style = CS_HREDRAW | CS_VREDRAW; + window_class.lpfnWndProc = window_proc; + window_class.cbClsExtra = 0; + window_class.cbWndExtra = 0; + window_class.hInstance = h_instance; + window_class.hIcon = LoadIcon(NULL, IDI_APPLICATION); + window_class.hCursor = LoadCursor(NULL, IDC_ARROW); + window_class.hbrBackground = GetSysColorBrush(COLOR_BTNFACE); + window_class.lpszMenuName = NULL; + window_class.lpszClassName = name.c_str(); + window_class.hIconSm = NULL; + + atom_ = ::RegisterClassExW(&window_class); + if (atom_ == 0) + throw Win32Error(::GetLastError(), "Failed to create window class."); +} +} // namespace cru::ui |