-
Notifications
You must be signed in to change notification settings - Fork 1
/
HelloWinBoxes.cpp
202 lines (158 loc) · 6 KB
/
HelloWinBoxes.cpp
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
#include <windows.h>
#include <gdiplus.h>
#include <gdiplusbrush.h>
#include <assert.h>
#pragma comment(lib, "kernel32.lib")
#pragma comment(lib, "user32.lib")
#pragma comment(lib, "Gdi32.lib")
#pragma comment(lib, "gdiplus.lib")
LRESULT CALLBACK WindowProcessMessages(HWND hwnd, UINT msg, WPARAM param, LPARAM lparam);
void draw(HDC hdc);
int WINAPI WinMain(HINSTANCE currentInstance, HINSTANCE previousInstance, PSTR cmdLine, INT cmdCount) {
// Initialize GDI+
Gdiplus::GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, nullptr);
// Register the window class
static TCHAR szClassName[] = TEXT("SHIV-SAN APP");
static TCHAR szWindowName[] = TEXT("Snake And Ladder Game");
WNDCLASS wc{};
wc.hInstance = currentInstance;
wc.lpszClassName = szClassName;
wc.hCursor = LoadCursor(nullptr, IDC_ARROW);
wc.hbrBackground = (HBRUSH)COLOR_WINDOW;
wc.lpfnWndProc = WindowProcessMessages;
RegisterClass(&wc);
// Create the window
CreateWindow(szClassName, szWindowName,
WS_OVERLAPPEDWINDOW | WS_VISIBLE, // Window style
CW_USEDEFAULT, CW_USEDEFAULT, // Window initial position
1100, 1100, // Window size
nullptr, nullptr, nullptr, nullptr);
// Window loop
MSG msg{};
while (GetMessage(&msg, nullptr, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
Gdiplus::GdiplusShutdown(gdiplusToken);
return 0;
}
LRESULT CALLBACK WindowProcessMessages(HWND hwnd, UINT msg, WPARAM param, LPARAM lparam) {
HDC hdc;
PAINTSTRUCT ps;
HBRUSH hBrush = NULL;
hBrush = (HBRUSH)GetStockObject(WHITE_BRUSH);
char* char_arr[10] = {"100", "99", "98", "97", "96", "95", "94", "93", "92", "91"};
LPCSTR display_char = NULL;
switch (msg) {
case WM_PAINT:
{
int i, x = 0, y = 0, x2 = 75, y2 = 75;
hdc = BeginPaint(hwnd, &ps);
//draw(hdc);
RECT rs;
rs.bottom = 75;
rs.left = 0;
rs.right = 75;
rs.top = 0;
for(i = 0; i < 10; ++i)
{
Rectangle(hdc, x, y, x2, y2);
TextOut(hdc, x+10, y+10, (LPCSTR)char_arr[i], 3);
//FillRect(hdc, &rs, hBrush);
// DrawText(hdc, (LPCTSTR)char_arr[i], 3, &rs, 0);
x += 75;
x2 += 75;
}
char* char_arr1[10] = {"81", "82", "83", "84", "85", "86", "87", "88", "89", "90"};
x = 0, y = 75, x2= 75, y2 = 150;
for(i = 0; i < 10; ++i)
{
Rectangle(hdc, x, y, x2, y2);
TextOut(hdc, x+10, y+10, (LPCSTR)char_arr1[i], 3);
x += 75;
x2 += 75;
}
char* char_arr2[10] = {"80", "79", "78", "77", "76", "75", "74", "73", "72", "71"};
x = 0, y = 150, x2= 75, y2 = 225;
for(i = 0; i < 10; ++i)
{
Rectangle(hdc, x, y, x2, y2);
TextOut(hdc, x+10, y+10, (LPCSTR)char_arr2[i], 3);
x += 75;
x2 += 75;
}
char* char_arr3[10] = {"61", "62", "63", "64", "65", "66", "67", "68", "69", "70"};
x = 0, y = 225, x2= 75, y2 = 300;
for(i = 0; i < 10; ++i)
{
Rectangle(hdc, x, y, x2, y2);
TextOut(hdc, x+10, y+10, (LPCSTR)char_arr3[i], 3);
x += 75;
x2 += 75;
}
char* char_arr4[10] = {"60", "59", "58", "57", "56", "55", "54", "53", "52", "51"};
x = 0, y = 300, x2= 75, y2 = 375;
for(i = 0; i < 10; ++i)
{
Rectangle(hdc, x, y, x2, y2);
TextOut(hdc, x+10, y+10, (LPCSTR)char_arr4[i], 3);
x += 75;
x2 += 75;
}
char* char_arr5[10] = {"41", "42", "43", "44", "45", "46", "47", "48", "49", "50"};
x = 0, y = 375, x2= 75, y2 = 450;
for(i = 0; i < 10; ++i)
{
Rectangle(hdc, x, y, x2, y2);
TextOut(hdc, x+10, y+10, (LPCSTR)char_arr5[i], 3);
x += 75;
x2 += 75;
}
char* char_arr6[10] = {"40", "39", "38", "37", "36", "35", "34", "33", "32", "31"};
x = 0, y = 450, x2= 75, y2 = 525;
for(i = 0; i < 10; ++i)
{
Rectangle(hdc, x, y, x2, y2);
TextOut(hdc, x+10, y+10, (LPCSTR)char_arr6[i], 3);
x += 75;
x2 += 75;
}
char* char_arr7[10] = {"21", "22", "23", "24", "25", "26", "27", "28", "29", "30"};
x = 0, y = 525, x2= 75, y2 = 600;
for(i = 0; i < 10; ++i)
{
Rectangle(hdc, x, y, x2, y2);
TextOut(hdc, x+10, y+10, (LPCSTR)char_arr7[i], 3);
x += 75;
x2 += 75;
}
char* char_arr8[10] = {"20", "19", "18", "17", "16", "15", "14", "13", "12", "11"};
x = 0, y = 600, x2= 75, y2 = 675;
for(i = 0; i < 10; ++i)
{
Rectangle(hdc, x, y, x2, y2);
TextOut(hdc, x+10, y+10, (LPCSTR)char_arr8[i], 3);
x += 75;
x2 += 75;
}
char* char_arr9[10] = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10"};
x = 0, y = 675, x2= 75, y2 = 750;
for(i = 0; i < 10; ++i)
{
Rectangle(hdc, x, y, x2, y2);
TextOut(hdc, x+10, y+10, (LPCSTR)char_arr9[i], 3);
x += 75;
x2 += 75;
}
EndPaint(hwnd, &ps);
return 0;
}
case WM_DESTROY:
PostQuitMessage(0);
return 0;
default:
return DefWindowProc(hwnd, msg, param, lparam);
}
}