aboutsummaryrefslogtreecommitdiff
path: root/src/ui/window_class.cpp
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2019-03-19 16:21:54 +0800
committercrupest <crupest@outlook.com>2019-03-19 16:21:54 +0800
commit5dc738a57930271194bd86673eb86f149096a7b2 (patch)
tree71174aba0d1c0918cc7d7a1be0b86ec0d5c20401 /src/ui/window_class.cpp
parent06edefebe8dfb138404397fb2c46732da6cd733a (diff)
downloadcru-5dc738a57930271194bd86673eb86f149096a7b2.tar.gz
cru-5dc738a57930271194bd86673eb86f149096a7b2.tar.bz2
cru-5dc738a57930271194bd86673eb86f149096a7b2.zip
...
Diffstat (limited to 'src/ui/window_class.cpp')
-rw-r--r--src/ui/window_class.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/ui/window_class.cpp b/src/ui/window_class.cpp
new file mode 100644
index 00000000..456d9492
--- /dev/null
+++ b/src/ui/window_class.cpp
@@ -0,0 +1,25 @@
+#include "window_class.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 std::runtime_error("Failed to create window class.");
+}
+} // namespace cru::ui