diff options
author | crupest <crupest@outlook.com> | 2022-05-15 13:56:40 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2022-05-15 13:56:40 +0800 |
commit | 9e0c9d3499bc50c3534b4dc500d8b5d0b5f22752 (patch) | |
tree | 7342f6991771fa31b16fd6a5ed892ff6025f3d05 /src/platform/gui/win/WindowClass.cpp | |
parent | 41de54bad2c0f857821fcc83f41af3334d068b6d (diff) | |
download | cru-9e0c9d3499bc50c3534b4dc500d8b5d0b5f22752.tar.gz cru-9e0c9d3499bc50c3534b4dc500d8b5d0b5f22752.tar.bz2 cru-9e0c9d3499bc50c3534b4dc500d8b5d0b5f22752.zip |
...
Diffstat (limited to 'src/platform/gui/win/WindowClass.cpp')
-rw-r--r-- | src/platform/gui/win/WindowClass.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/platform/gui/win/WindowClass.cpp b/src/platform/gui/win/WindowClass.cpp new file mode 100644 index 00000000..cac50eda --- /dev/null +++ b/src/platform/gui/win/WindowClass.cpp @@ -0,0 +1,28 @@ +#include "cru/platform/gui/win/WindowClass.h" + +#include "cru/platform/gui/win/Exception.h" + +namespace cru::platform::gui::win { +WindowClass::WindowClass(std::wstring name, WNDPROC window_proc, + HINSTANCE h_instance) + : name_(std::move(name)) { + WNDCLASSEXW window_class; + window_class.cbSize = sizeof(WNDCLASSEXW); + + 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(), u"Failed to create window class."); +} +} // namespace cru::platform::gui::win |