Home
Tutorials
Code Snippets
Code Samples
Downloads
Links

The Blog
Our Projects
About
Contact

::Add RageStorm to Favorites!::

The Blog | Our Projects | Guest Book | About | Contact

 
Code Snippet - Small Console CRT
Author:Arkon
Category:Win32API
File Size:965 Bytes
Uploaded at:27-Nov-02 08:09:17 pm
Description:
  Colors for text or background, clrscr and gotoxy... for console applications only.
  
// Ever tried to call clrscr() in a Win32 Console Application?

void ClrScr()
{
 HANDLE hStdout; 
 DWORD writtenchars, writtenattrs;
 COORD coord = {0, 0};
 hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
 CONSOLE_SCREEN_BUFFER_INFO cbsi;
 GetConsoleScreenBufferInfo(hStdout, &cbsi);
 FillConsoleOutputCharacter(hStdout, 0, cbsi.dwSize.X*cbsi.dwSize.Y, coord, &writtenchars);
 FillConsoleOutputAttribute(hStdout, cbsi.wAttributes, cbsi.dwSize.X*cbsi.dwSize.Y, coord, &writtenattrs);
 SetConsoleCursorPosition(hStdout, coord);
}

// What about gotoxy?

void GotoXY(int x, int y)

 COORD coord = {x, y};
 SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}

// hmm textcolor?
FOREGROUND_BLUE
FOREGROUND_GREEN
FOREGROUND_RED
FOREGROUND_INTENSITY

BACKGROUND_BLUE
BACKGROUND_GREEN
BACKGROUND_RED
BACKGROUND_INTENSITY
void TextColor(unsigned char attr)
{
 SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), attr);
}
NOTE:
Comments that will hurt anyone in any way will be deleted.
Don't ask for features, advertise or curse.
If you want to leave a message to the author use the contacts,
if you have any question in relation to your comments please use the forum.
Comments which violate any of these requests will be deleted without further
notice. Use the comment system decently.

Post your comment:
Name:
email:
Comment:
::Top 5 Tutorials::
Embedded Python[117082]
2D Rotated Rectangles Collision Detection[88999]
Keyboard Hook[77347]
UDP[65892]
HTTP Proxy[41228]

::Top 5 Samples::
2D ColDet Rotated Rectangles[11562]
PS2 Mouse Driver[6960]
Wave Format Player[5793]
Reading FAT12[5621]
CodeGuru[5361]


All rights reserved to RageStorm © 2009