11#include <backends/imgui_impl_win32.h>
15void scl::windows_window::Create()
18 WNDCLASS window_class {};
20 const std::string window_class_name =
Data.
Title +
"Window Class Name.";
21 window_class.lpszClassName = window_class_name.c_str();
22 window_class.lpszMenuName =
nullptr;
23 window_class.style = CS_VREDRAW | CS_HREDRAW;
25 window_class.hbrBackground = (HBRUSH)COLOR_WINDOW;
26 window_class.hCursor = LoadCursor(InstanceHandle, IDC_CROSS);
27 window_class.hIcon = LoadIcon(InstanceHandle, IDI_APPLICATION);
28 window_class.hInstance = InstanceHandle;
30 window_class.cbClsExtra = 0;
32 window_class.lpfnWndProc = WinProc;
35 SCL_CORE_ASSERT(RegisterClass(&window_class),
"Window class creation failed.");
39 window_class_name.c_str(),
Data.
Title.c_str(),
40 WS_OVERLAPPEDWINDOW | WM_SHOWWINDOW,
41 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
42 nullptr,
nullptr, InstanceHandle,
reinterpret_cast<void *
>(
this)
49 window(Width, Height, Title)
57 while (PeekMessage(&msg,
nullptr, 0, 0, PM_REMOVE))
59 if (msg.message == WM_QUIT)
61 TranslateMessage(&msg);
62 DispatchMessage(&msg);
72 SetWindowText(Handle, NewTitle.c_str());
77 PostMessage(Handle, WM_CLOSE, 0, 0);
84 WPARAM wParam, LPARAM lParam)
90 (UINT_PTR)((CREATESTRUCT *)lParam)->lpCreateParams
97 windows_window *win =
reinterpret_cast<windows_window *
>(GetWindowLongPtr(hWnd, 0));
102 HANDLE_MSG(hWnd, WM_CREATE, win->OnCreate);
103 HANDLE_MSG(hWnd, WM_SIZE, win->OnSize);
104 HANDLE_MSG(hWnd, WM_DESTROY, win->OnDestroy);
105 HANDLE_MSG(hWnd, WM_CLOSE, win->OnClose);
106 HANDLE_MSG(hWnd, WM_TIMER, win->OnTimer);
108 HANDLE_MSG(hWnd, WM_ERASEBKGND, win->OnEraseBackground);
109 HANDLE_MSG(hWnd, WM_PAINT, win->OnPaint);
110 HANDLE_MSG(hWnd, WM_ACTIVATE, win->OnActivate);
112 HANDLE_MSG(hWnd, WM_MOUSEMOVE, win->OnMMove);
113 HANDLE_MSG(hWnd, WM_MOUSEWHEEL, win->OnMWheel);
114 HANDLE_MSG(hWnd, WM_LBUTTONDOWN, win->OnMButDown);
115 HANDLE_MSG(hWnd, WM_LBUTTONDBLCLK, win->OnMButDown);
116 HANDLE_MSG(hWnd, WM_LBUTTONUP, win->OnMButUp);
117 HANDLE_MSG(hWnd, WM_RBUTTONDOWN, win->OnMButDown);
118 HANDLE_MSG(hWnd, WM_RBUTTONDBLCLK, win->OnMButDown);
119 HANDLE_MSG(hWnd, WM_RBUTTONUP, win->OnMButUp);
120 HANDLE_MSG(hWnd, WM_MBUTTONDOWN, win->OnMButDown);
121 HANDLE_MSG(hWnd, WM_MBUTTONDBLCLK, win->OnMButDown);
122 HANDLE_MSG(hWnd, WM_MBUTTONUP, win->OnMButUp);
124 HANDLE_MSG(hWnd, WM_KEYDOWN, win->OnKey);
125 HANDLE_MSG(hWnd, WM_KEYUP, win->OnKey);
128 return DefWindowProc(hWnd, Msg, wParam, lParam);
#define SCL_CORE_ASSERT(expr,...)
void FlipFullscreen() override
void ChangeTitle(const std::string &NewTitle) override
windows_window(int Width, int Height, const std::string &Title)
#define SCL_CORE_SUCCES(...)
Sculpto library prehompiled header. Defines common definitions, includes commonly used modules.
IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)