-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLoadingWidget.cpp
More file actions
66 lines (53 loc) · 1.31 KB
/
LoadingWidget.cpp
File metadata and controls
66 lines (53 loc) · 1.31 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
#include <windows.h>
HDC hdc;
RECT rect;
HBRUSH hbr;
HBRUSH hbrsc;
int x = 10;
int y = 10;
bool running = true;
LRESULT CALLBACK wndproc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_CLOSE:
running = false;
PostQuitMessage(0);
break;
case WM_PAINT:
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE previnstance, LPSTR args, int CmdShow)
{
MSG msg = { 0 };
WNDCLASS wc = { 0 };
wc.lpfnWndProc = wndproc;
wc.hInstance = hinstance;
wc.hbrBackground = (HBRUSH)CreateSolidBrush(RGB(255, 255, 255));
wc.lpszClassName = L"window";
if (!RegisterClass(&wc))
return 1;
HWND hwnd = CreateWindow(wc.lpszClassName,
L"Loading",
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
400, 400, 640, 130, 0, 0, hinstance, NULL);
hdc = GetDC(hwnd);
hbr = CreateSolidBrush(RGB(0, 255, 0));
hbrsc = CreateSolidBrush(RGB(255, 255, 255));
while (running) {
if(GetMessage(&msg, NULL, 0, 0) > 0)
DispatchMessage(&msg);
FillRect(hdc, &rect, hbr);
Sleep(10);
FillRect(hdc, &rect, hbrsc);
rect = { x, 30, x + y, 40 };
if (x > 300) { y--; x++; }
else if (y < 60)y++;
else x++;
if (x > 355) { x = 10; y = 10; }
}
}