here's the clrscr() function found here :
I got three questions about it :Code:void clrscr(void) { COORD coordScreen = { 0, 0 }; DWORD cCharsWritten; CONSOLE_SCREEN_BUFFER_INFO csbi; DWORD dwConSize; HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); GetConsoleScreenBufferInfo(hConsole, &csbi); dwConSize = csbi.dwSize.X * csbi.dwSize.Y; FillConsoleOutputCharacter(hConsole, TEXT(' '), dwConSize, coordScreen, &cCharsWritten); GetConsoleScreenBufferInfo(hConsole, &csbi); FillConsoleOutputAttribute(hConsole, csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten); SetConsoleCursorPosition(hConsole, coordScreen); }
1. Why did the author call GetConsoleScreenBufferInfo() again although csbi already contains the screen attributes? (red text)
2. Whats the difference between using ' ' and TEXT(' ') ? i searched mdsn but couldn't find anything. (blue text)
3. And finally , is the following clrscr() function equivalent to the above or not (if not , wich one is better) :
I just took off the other GetConsoleScreenBufferInfo() and specified the character attributes myself.Code:void clrscr(void) { COORD coordScreen = { 0, 0 }; DWORD cCharsWritten; CONSOLE_SCREEN_BUFFER_INFO csbi; DWORD dwConSize; HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); GetConsoleScreenBufferInfo(hConsole, &csbi); dwConSize = csbi.dwSize.X * csbi.dwSize.Y; FillConsoleOutputCharacter(hConsole, ' ', dwConSize, coordScreen, &cCharsWritten); FillConsoleOutputAttribute(hConsole, 0 , dwConSize, coordScreen, &cCharsWritten); SetConsoleCursorPosition(hConsole, coordScreen); }
Thanks for your time.



LinkBack URL
About LinkBacks


