-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWindowHelper.cpp
More file actions
41 lines (31 loc) · 1.05 KB
/
WindowHelper.cpp
File metadata and controls
41 lines (31 loc) · 1.05 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
#include "Defines.h"
#include "WindowHelper.h"
LRESULT CALLBACK WindowProc(HWND hWind, UINT message, WPARAM wParam, LPARAM lParam) // Callback = executable code sent as an argument to another code
{
switch (message)
{
case WM_DESTROY:
PostQuitMessage(0);
return 0;
default:
break;
}
return DefWindowProc(hWind, message, wParam, lParam);
}
bool SetupWindow(HINSTANCE instance, UINT width, UINT height, int nCmdShow, HWND& window)
{
const wchar_t CLASS_NAME[] = L"Demo Window Class";
WNDCLASS wc = {};
wc.lpfnWndProc = WindowProc;
wc.hInstance = instance;
wc.lpszClassName = CLASS_NAME;
RegisterClass(&wc);
window = CreateWindowEx(0, CLASS_NAME, L"Demo Window", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, width, height, nullptr, nullptr, instance, nullptr);
if (window == nullptr)
{
std::cerr << "HWND was nullptr, last error: " << GetLastError() << std::endl;
return false;
}
ShowWindow(window, nCmdShow);
return true;
}