diff options
author | crupest <crupest@outlook.com> | 2020-10-30 00:07:57 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-10-30 00:07:57 +0800 |
commit | 6aa2201797a9ed64ce0178215ae941d0c5f09579 (patch) | |
tree | 9a74ee8d9f616afbe693ef7825a71474850831b5 /src/win/gui/WindowClass.cpp | |
parent | b4cb4fb7552d35c267bdb66913e4c822f16346ab (diff) | |
download | cru-6aa2201797a9ed64ce0178215ae941d0c5f09579.tar.gz cru-6aa2201797a9ed64ce0178215ae941d0c5f09579.tar.bz2 cru-6aa2201797a9ed64ce0178215ae941d0c5f09579.zip |
...
Diffstat (limited to 'src/win/gui/WindowClass.cpp')
-rw-r--r-- | src/win/gui/WindowClass.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/win/gui/WindowClass.cpp b/src/win/gui/WindowClass.cpp new file mode 100644 index 00000000..a033d091 --- /dev/null +++ b/src/win/gui/WindowClass.cpp @@ -0,0 +1,28 @@ +#include "cru/win/gui/WindowClass.hpp" + +#include "cru/win/gui/Exception.hpp" + +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(), "Failed to create window class."); +} +} // namespace cru::platform::gui::win |