-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathWindow.cpp
More file actions
96 lines (77 loc) · 1.78 KB
/
Window.cpp
File metadata and controls
96 lines (77 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#include <Windows.h>
namespace Window
{
HWND hWindow(nullptr);
LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
LRESULT result = 0;
switch (message)
{
case WM_SIZE:
{
UINT width = LOWORD(lParam);
UINT height = HIWORD(lParam);
//OnResize(width, height);
}
result = 0;
break;
case WM_DISPLAYCHANGE:
InvalidateRect(hWnd, nullptr, false);
result = 0;
break;
case WM_PAINT:
//OnRender();
ValidateRect(hWnd, nullptr);
result = 0;
break;
case WM_LBUTTONDOWN:
//OnClick(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
break;
case WM_DESTROY:
PostQuitMessage(0);
result = 1;
break;
case WM_CHAR:
//CharInput(static_cast<wchar_t>(wParam));
result = 0;
break;
case WM_COMMAND:
default:
result = DefWindowProc(hWnd, message, wParam, lParam);
break;
}
return result;
}
void Init()
{
const UINT width(CW_USEDEFAULT);
const UINT height(CW_USEDEFAULT);
const wchar_t* title = L"Hello Window";
//Register the window class.
WNDCLASSEX wcex = { sizeof(WNDCLASSEX) };
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = WindowProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = GetModuleHandle(0);
wcex.hIcon = nullptr;
wcex.hCursor = LoadCursor(NULL, IDI_APPLICATION);
wcex.hbrBackground = nullptr;
wcex.lpszMenuName = nullptr;
wcex.lpszClassName = L"arbitraryclassname";
wcex.hIconSm = nullptr;
RegisterClassEx(&wcex);
hWindow = CreateWindowEx(WS_EX_ACCEPTFILES, wcex.lpszClassName, title, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, width, height, nullptr, nullptr, GetModuleHandle(0), nullptr);
ShowWindow(hWindow, SW_SHOWNORMAL);
UpdateWindow(hWindow);
}
void Run()
{
MSG msg;
while (GetMessage(&msg, nullptr, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
}