Author | Message | Time |
---|---|---|
Eli_1 | I saw a console app, Half-Life's HLTV, display a little green banner at the top of the window that displays data. The data constantly changes and doesn't move from the top. I researched this some and I think the way to do it is with FillConsoleOutputAttribute, but I can't get it working. Can anyone explain how to do this to me? | April 25, 2004, 11:30 PM |
Eli_1 | I got it working. Code: [code] #include <windows.h> #include <wincon.h> #include <stdio.h> #include <string.h> #include <conio.h> void writeLine(LPCTSTR lpString, WORD wColor, int X, int Y, DWORD dwSize) { HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE); COORD coord; DWORD cWritten; coord.X = X; coord.Y = Y; char ctmp = ' '; FillConsoleOutputCharacter(hStdout, ctmp, dwSize, coord, &cWritten); FillConsoleOutputAttribute(hStdout, wColor, dwSize, coord, &cWritten); WriteConsoleOutputCharacter(hStdout, lpString, strlen(lpString), coord, &cWritten); } int main() { clrscr(); for (int i=0; i<50; i++) { printf("test3\n"); writeLine("test", BACKGROUND_GREEN, 0, 0, 50); writeLine("test2", BACKGROUND_RED, 0, 1, 50); Sleep(100); } return 0; }[/code] Output: Legend: !!! = Green Background III = Red Background [quote] Test!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Test2IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII test3 test3 test3 test3 ...[/quote] Anyone know of a better way of doing this? | April 26, 2004, 1:10 AM |