This repository was archived by the owner on Sep 3, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathResources.cpp
More file actions
114 lines (97 loc) · 2.5 KB
/
Resources.cpp
File metadata and controls
114 lines (97 loc) · 2.5 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
// Resources.cpp
// Header required to help detect window version
#include <sdkddkver.h>
// Macro used to reduce namespace pollution
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
// Reference for various Win32 API functions and
// structure declarations.
#include <Windows.h>
// Header needed for unicode adjustment support
#include <tchar.h>
//
//
// WndProc - Window procedure
//
//
LRESULT
CALLBACK
WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_DESTROY:
::PostQuitMessage(0);
break;
default:
return ::DefWindowProc(hWnd, uMsg, wParam, lParam);
}
return 0;
}
//
//
// WinMain - Win32 application entry point.
//
//
int
APIENTRY
_tWinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPWSTR lpCmdLine,
int nShowCmd)
{
// Setup window class attributes.
WNDCLASSEX wcex;
ZeroMemory(&wcex, sizeof(wcex));
wcex.cbSize = sizeof(wcex); // WNDCLASSEX size in bytes
wcex.style = CS_HREDRAW | CS_VREDRAW; // Window class styles
wcex.lpszClassName = TEXT("MYFIRSTWINDOWCLASS"); // Window class name
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); // Window background brush color.
wcex.hCursor = LoadCursor(hInstance, IDC_ARROW); // Window cursor
wcex.lpfnWndProc = WndProc; // Window procedure associated to this window class.
wcex.hInstance = hInstance; // The application instance.
// Register window and ensure registration success.
if (!RegisterClassEx(&wcex))
return 1;
// Setup window initialization attributes.
CREATESTRUCT cs;
ZeroMemory(&cs, sizeof(cs));
cs.x = 0; // Window X position
cs.y = 0; // Window Y position
cs.cx = 640; // Window width
cs.cy = 480; // Window height
cs.hInstance = hInstance; // Window instance.
cs.lpszClass = wcex.lpszClassName; // Window class name
cs.lpszName = TEXT("My First Window"); // Window title
cs.style = WS_OVERLAPPEDWINDOW; // Window style
// Create the window.
HWND hWnd = ::CreateWindowEx(
cs.dwExStyle,
cs.lpszClass,
cs.lpszName,
cs.style,
cs.x,
cs.y,
cs.cx,
cs.cy,
cs.hwndParent,
cs.hMenu,
cs.hInstance,
cs.lpCreateParams);
// Validate window.
if (!hWnd)
return 1;
// Display the window.
::ShowWindow(hWnd, SW_SHOWDEFAULT);
::UpdateWindow(hWnd);
// Main message loop.
MSG msg;
while (::GetMessage(&msg, hWnd, 0, 0) > 0)
::DispatchMessage(&msg);
// Unregister window class, freeing the memory that was
// previously allocated for this window.
::UnregisterClass(wcex.lpszClassName, hInstance);
return (int)msg.wParam;
}