-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path(Lab_4) Timer
More file actions
153 lines (113 loc) · 3 KB
/
(Lab_4) Timer
File metadata and controls
153 lines (113 loc) · 3 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
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
#include "stdafx.h"
#include "Лаба4.h"
#include <string>
#include <iostream>
#include <windows.h>
#include <stdio.h>
#define CLASSNAME "hhhffhfhhfhhff"
#define MAINNAME "Main Window"
LRESULT CALLBACK WindowProcedure(HWND, UINT, WPARAM, LPARAM);
char szClassName[] = "WindowsApp";
int WINAPI WinMain(HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nFunsterStil)
{
HWND hwnd;
MSG messages;
WNDCLASSEX wincl = { 0 };
wincl.hInstance = hThisInstance;
wincl.lpszClassName = CLASSNAME;
wincl.lpfnWndProc = WindowProcedure;
wincl.cbSize = sizeof(WNDCLASSEX);
wincl.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
if (!RegisterClassEx(&wincl))
return 0;
HMENU hm = LoadMenu(hThisInstance, MAKEINTRESOURCE(IDC_MY4));
int cx = (GetSystemMetrics(SM_CXSCREEN));
int cy = (GetSystemMetrics(SM_CYSCREEN));
int y = cy / 10;
int x = cx / 10;
hwnd = CreateWindow(CLASSNAME, MAINNAME, WS_OVERLAPPEDWINDOW,
x, y, cx - 2 * x, cy - 2 * y, NULL, hm, hThisInstance, NULL);
ShowWindow(hwnd, nFunsterStil);
UpdateWindow(hwnd);
while (GetMessage(&messages, NULL, 0, 0))
{
DispatchMessage(&messages);
}
return 0;
}
LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) {
char OurTex[] = "HAHAHAHAHAHAHAH";
HDC hdc;
PAINTSTRUCT ps;
RECT rect;
switch (message)
{
case WM_CREATE:
EnableMenuItem(GetMenu(hwnd), 1, MF_DISABLED);
SetTimer(hwnd, 1, 500, NULL);
break;
case WM_TIMER: {
LPARAM lp = (LPARAM)GetWindowLong(hwnd, GWL_USERDATA);
double start = (double)LOWORD(lp);
double end1 = start + 10;;
if (end1 >= 360)
{
end1 -= 360;
}
lp = MAKELPARAM(end1, HIWORD(lp));
SetWindowLong(hwnd, GWL_USERDATA, (LONG)lp);
InvalidateRect(hwnd, NULL, TRUE);
}
break;
case WM_COMMAND:
switch (wParam) {
case 0:
KillTimer(hwnd, 1);
DestroyWindow(hwnd);
break;
case 1:
KillTimer(hwnd, 1);
EnableMenuItem(GetMenu(hwnd), 1, MF_DISABLED);
EnableMenuItem(GetMenu(hwnd), 2, MF_ENABLED);
break;
case 2:
SetTimer(hwnd, 1, 500, NULL);
EnableMenuItem(GetMenu(hwnd), 1, MF_ENABLED);
EnableMenuItem(GetMenu(hwnd), 2, MF_DISABLED);
break;
}
break;
case WM_SIZE:
InvalidateRect(hwnd, NULL, TRUE);
break;
case WM_DESTROY: {
KillTimer(hwnd, 1);
PostQuitMessage(0);
}
break;
case WM_PAINT: {
hdc = BeginPaint(hwnd, &ps);
GetClientRect(hwnd, &rect);
LOGFONT coup = { 0 };
HANDLE hfnt, hfntPrev;
LPARAM lparam = (LPARAM)GetWindowLong(hwnd, GWL_USERDATA);
double angle = (double)LOWORD(lparam);
coup.lfHeight = 0;
coup.lfWeight = FW_NORMAL;
coup.lfEscapement = (long)angle * 50;
coup.lfOrientation = (long)angle * 30;
hfnt = CreateFontIndirect(&coup);
hfntPrev = SelectObject(hdc, hfnt);
SetTextAlign(hdc, TA_CENTER | TA_BASELINE);
ExtTextOut(hdc, rect.right / 2, rect.bottom / 2, ETO_CLIPPED, &rect, (LPCSTR)&OurTex, 3, NULL);
SelectObject(hdc, hfntPrev);
DeleteObject(hfnt);
EndPaint(hwnd, &ps);
}
break;
}
return DefWindowProc(hwnd, message, wParam, lParam);
}