-
Notifications
You must be signed in to change notification settings - Fork 0
/
Бегущая строка.cpp
73 lines (62 loc) · 1.82 KB
/
Бегущая строка.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
#include <tchar.h>
#include <Windows.h>
VOID CALLBACK TimerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime);
LRESULT CALLBACK WindowProcedure(HWND, UINT, WPARAM, LPARAM);
INT WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR szCmdLine, INT nCmdShow)
{
TCHAR szClassWindow[] = L"Бегущая строка... ";
WNDCLASSEX wc = {};
wc.cbClsExtra = 0;
wc.cbSize = sizeof(wc);
wc.cbWndExtra = 0;
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
wc.hInstance = hInstance;
wc.lpfnWndProc = WindowProcedure;
wc.lpszClassName = szClassWindow;
wc.lpszMenuName = NULL;
wc.style = CS_HREDRAW | CS_VREDRAW;
INT nExitCode = 0;
if (RegisterClassEx(&wc))
{
HWND hWindow = CreateWindowEx(0, szClassWindow, szClassWindow,
WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL,
NULL, hInstance, NULL);
ShowWindow(hWindow, nCmdShow);
UpdateWindow(hWindow);
MSG message = {};
SetTimer(hWindow, 1, 100, TimerProc);
while (GetMessage(&message, NULL, 0, 0))
{
TranslateMessage(&message);
DispatchMessage(&message);
}
nExitCode = message.wParam;
}
return nExitCode;
}
VOID CALLBACK TimerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
{
TCHAR oldTitle[20];
TCHAR newTitle[20];
GetWindowText(hwnd, oldTitle, 20);
for (int i = 0; i < 20; i++)
newTitle[i] = oldTitle[i + 1];
newTitle[18] = oldTitle[0];
newTitle[19] = '\0';
SetWindowText(hwnd, newTitle);
}
LRESULT CALLBACK WindowProcedure(HWND hWindow, UINT nMessage, WPARAM wParam, LPARAM lParam)
{
switch (nMessage)
{
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWindow, nMessage, wParam, lParam);
break;
}
}