4 * --------------------------------------------------------------------
6 * This software is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public License as
8 * published by the Free Software Foundation; either version 2 of the
9 * License, or (at your option) any later version.
11 * This software is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this software; see the file COPYING.LIB. If
18 * not, write to the Free Software Foundation, Inc., 675 Mass Ave,
19 * Cambridge, MA 02139, USA.
21 * --------------------------------------------------------------------
22 * ReactOS Coders Console Parade
32 // #define DISPLAY_COORD
34 LPCWSTR app_name
= L
"notevil";
38 CONSOLE_SCREEN_BUFFER_INFO ScreenBufferInfo
;
42 WriteStringAt(LPWSTR lpString
,
49 if (!lpString
|| *lpString
== 0) return;
51 wLen
= wcslen(lpString
);
53 /* Don't bother writing text when erasing */
56 WriteConsoleOutputCharacterW(ScreenBuffer
,
63 FillConsoleOutputAttribute(ScreenBuffer
,
78 wsprintf(buf
, L
"x=%02d y=%02d", c
.X
, c
.Y
);
80 WriteStringAt(buf
, xy
,
81 BACKGROUND_RED
| BACKGROUND_GREEN
| BACKGROUND_BLUE
);
83 #endif /* def DISPLAY_COORD */
87 GetNextString(LPWSTR Buffer
,
91 if (RES_LAST_INDEX
== *Index
)
92 *Index
= RES_FIRST_INDEX
;
96 LoadStringW(myself
, *Index
, Buffer
, BufferSize
);
103 LPWSTR szTitle
= L
"ReactOS Coders Console Parade";
106 xy
.X
= (ScreenBufferInfo
.dwSize
.X
- wcslen(szTitle
)) / 2;
107 xy
.Y
= ScreenBufferInfo
.dwSize
.Y
/ 2;
109 WriteStringAt(szTitle
, xy
,
110 FOREGROUND_GREEN
| FOREGROUND_INTENSITY
);
114 #define RES_DELAY_CHANGE 12
115 #define RES_BUFFER_SIZE 1024
119 WCHAR NameString
[RES_BUFFER_SIZE
];
123 INT n
= RES_DELAY_CHANGE
;
128 xy
.X
= ScreenBufferInfo
.dwSize
.X
/ 2;
129 xy
.Y
= ScreenBufferInfo
.dwSize
.Y
/ 2;
133 if (n
== RES_DELAY_CHANGE
)
137 GetNextString(NameString
,
140 NameLength
= wcslen(NameString
);
143 if ((wColor
& 0x000F) == 0)
151 else if (xy
.X
>= ScreenBufferInfo
.dwSize
.X
- NameLength
- 1)
163 else if (xy
.Y
>= ScreenBufferInfo
.dwSize
.Y
- 1)
172 #endif /* def DISPLAY_COORD */
175 WriteStringAt(NameString
, xy
, wColor
);
176 WaitForSingleObject(WaitableTimer
, INFINITE
);
177 WriteStringAt(NameString
, xy
, 0);
182 int wmain(int argc
, WCHAR
* argv
[])
186 COORD Coord
= { 0, 0 };
188 myself
= GetModuleHandle(NULL
);
190 GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE
),
192 ScreenBufferInfo
.dwSize
.X
= ScreenBufferInfo
.srWindow
.Right
- ScreenBufferInfo
.srWindow
.Left
+ 1;
193 ScreenBufferInfo
.dwSize
.Y
= ScreenBufferInfo
.srWindow
.Bottom
- ScreenBufferInfo
.srWindow
.Top
+ 1;
194 ScreenBuffer
= CreateConsoleScreenBuffer(GENERIC_WRITE
,
197 CONSOLE_TEXTMODE_BUFFER
,
199 if (ScreenBuffer
== INVALID_HANDLE_VALUE
)
201 wprintf(L
"%s: could not create a new screen buffer\n", app_name
);
205 /* Fill buffer with black background */
206 FillConsoleOutputAttribute(ScreenBuffer
,
208 ScreenBufferInfo
.dwSize
.X
* ScreenBufferInfo
.dwSize
.Y
,
212 WaitableTimer
= CreateWaitableTimer(NULL
, FALSE
, NULL
);
213 if (WaitableTimer
== INVALID_HANDLE_VALUE
)
215 wprintf(L
"CreateWaitabletimer() failed\n");
218 lint
.QuadPart
= -2000000;
219 if (!SetWaitableTimer(WaitableTimer
, &lint
, 200, NULL
, NULL
, FALSE
))
221 wprintf(L
"SetWaitableTimer() failed: 0x%lx\n", GetLastError());
224 SetConsoleActiveScreenBuffer(ScreenBuffer
);
226 CloseHandle(ScreenBuffer
);