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
|
#define STRICT
#include <windows.h>
#include <windowsx.h>
#include <commctrl.h>
#include <tchar.h>
#define WND_CLASS_NAME TEXT("Scratch")
HINSTANCE g_hinst;
BOOL OnCreate(HWND hwnd, LPCREATESTRUCT lpcs)
{
return TRUE;
}
void OnDestroy(HWND hwnd)
{
PostQuitMessage(0);
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT uiMsg, WPARAM wParam,
LPARAM lParam)
{
switch (uiMsg)
{
HANDLE_MSG(hwnd, WM_CREATE, OnCreate);
HANDLE_MSG(hwnd, WM_DESTROY, OnDestroy);
}
return DefWindowProc(hwnd, uiMsg, wParam, lParam);
}
BOOL RegisterWindowClass()
{
WNDCLASS wc;
ATOM atom;
wc.style = 0;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = g_hinst;
wc.hIcon = NULL;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
wc.lpszMenuName = NULL;
wc.lpszClassName = WND_CLASS_NAME;
atom = RegisterClass(&wc);
return (atom != 0);
}
int WINAPI _tWinMain(HINSTANCE hinst, HINSTANCE hinstPrev,
LPTSTR lpCmdLine, int nCmdShow)
{
INITCOMMONCONTROLSEX icc;
int ret = EXIT_FAILURE;
g_hinst = hinst;
// We will need the tooltip common control
icc.dwSize = sizeof(icc);
icc.dwICC = ICC_WIN95_CLASSES;
if (InitCommonControlsEx(&icc))
{
if (RegisterWindowClass())
{
HWND hwnd = CreateWindow
(
WND_CLASS_NAME,
TEXT("Scratch"),
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
NULL,
NULL,
hinst,
);
if (hwnd != NULL)
{
MSG msg;
(void) ShowWindow(hwnd, nCmdShow);
while (GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
ret = EXIT_SUCCESS;
}
}
}
return ret;
}
|