#include <windows.h>
#include <stdio.h>
BOOL (WINAPI *SetConsoleDisplayMode)(HANDLE hConsoleOutput, DWORD dwFlags, PCOORD lpNewScreenBufferSize);
#define PrintText(s) WriteFile(hConsole, (s), lstrlen((s)), &dwWrite, NULL)
#define COLOR_BLACK 0
#define COLOR_BLUE 1
#define COLOR_GREEN 2
#define COLOR_AQUA 3
#define COLOR_RED 4
#define COLOR_PURPLE 5
#define COLOR_YELLOW 6
#define COLOR_WHITE 7
#define COLOR_GRAY 8
#define COLOR_LTBLUE 9
#define COLOR_LTGREEN 10
#define COLOR_LTAQUA 11
#define COLOR_LTRED 12
#define COLOR_LTPURPLE 13
#define COLOR_LTYELLOW 14
#define COLOR_LTWHITE 15
int main(int argc, char *argv[])
{
HANDLE hConsole;
HMODULE hKernel;
DWORD dwWrite;
COORD zeroCoord = { 0, 0 }, coordSize = { 80, 25 };
CHAR szBuf[32];
// get function handle
hKernel = GetModuleHandle("kernel32");
if(!hKernel) return 1;
*(FARPROC *)&SetConsoleDisplayMode = GetProcAddress(hKernel, "SetConsoleDisplayMode");
// setup console
hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleScreenBufferSize(hConsole, coordSize);
SetConsoleDisplayMode(hConsole, 1, NULL);
FillConsoleOutputAttribute(hConsole, (COLOR_BLUE << 4) | COLOR_LTWHITE, (80 * 25), zeroCoord, &dwWrite);
FillConsoleOutputCharacter(hConsole, ' ', (80 * 25), zeroCoord, &dwWrite);
// output title
SetConsoleTextAttribute(hConsole, (COLOR_RED << 4) | COLOR_LTYELLOW);
PrintText(" Console Colour Test - by Napalm \n");
// output reference table
SetConsoleTextAttribute(hConsole, (COLOR_BLUE << 4) | COLOR_LTWHITE);
PrintText(" 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 Back\n");
for(int fore = 0; fore < 16; fore++){
SetConsoleTextAttribute(hConsole, (COLOR_BLUE << 4) | COLOR_LTWHITE);
wsprintf(szBuf, " %02d ", fore);
PrintText(szBuf);
for(int back = 0; back < 16; back++){
SetConsoleTextAttribute(hConsole, (back << 4) | fore);
PrintText("##");
SetConsoleTextAttribute(hConsole, (COLOR_BLUE << 4) | COLOR_LTWHITE);
PrintText(" ");
}
PrintText("\n");
}
// wait for user input before closing
SetConsoleTextAttribute(hConsole, (COLOR_BLUE << 4) | COLOR_LTWHITE);
PrintText(" Fore\n\n Press enter to quit...");
getchar();
return 0;
}
#include <stdio.h>
BOOL (WINAPI *SetConsoleDisplayMode)(HANDLE hConsoleOutput, DWORD dwFlags, PCOORD lpNewScreenBufferSize);
#define PrintText(s) WriteFile(hConsole, (s), lstrlen((s)), &dwWrite, NULL)
#define COLOR_BLACK 0
#define COLOR_BLUE 1
#define COLOR_GREEN 2
#define COLOR_AQUA 3
#define COLOR_RED 4
#define COLOR_PURPLE 5
#define COLOR_YELLOW 6
#define COLOR_WHITE 7
#define COLOR_GRAY 8
#define COLOR_LTBLUE 9
#define COLOR_LTGREEN 10
#define COLOR_LTAQUA 11
#define COLOR_LTRED 12
#define COLOR_LTPURPLE 13
#define COLOR_LTYELLOW 14
#define COLOR_LTWHITE 15
int main(int argc, char *argv[])
{
HANDLE hConsole;
HMODULE hKernel;
DWORD dwWrite;
COORD zeroCoord = { 0, 0 }, coordSize = { 80, 25 };
CHAR szBuf[32];
// get function handle
hKernel = GetModuleHandle("kernel32");
if(!hKernel) return 1;
*(FARPROC *)&SetConsoleDisplayMode = GetProcAddress(hKernel, "SetConsoleDisplayMode");
// setup console
hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleScreenBufferSize(hConsole, coordSize);
SetConsoleDisplayMode(hConsole, 1, NULL);
FillConsoleOutputAttribute(hConsole, (COLOR_BLUE << 4) | COLOR_LTWHITE, (80 * 25), zeroCoord, &dwWrite);
FillConsoleOutputCharacter(hConsole, ' ', (80 * 25), zeroCoord, &dwWrite);
// output title
SetConsoleTextAttribute(hConsole, (COLOR_RED << 4) | COLOR_LTYELLOW);
PrintText(" Console Colour Test - by Napalm \n");
// output reference table
SetConsoleTextAttribute(hConsole, (COLOR_BLUE << 4) | COLOR_LTWHITE);
PrintText(" 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 Back\n");
for(int fore = 0; fore < 16; fore++){
SetConsoleTextAttribute(hConsole, (COLOR_BLUE << 4) | COLOR_LTWHITE);
wsprintf(szBuf, " %02d ", fore);
PrintText(szBuf);
for(int back = 0; back < 16; back++){
SetConsoleTextAttribute(hConsole, (back << 4) | fore);
PrintText("##");
SetConsoleTextAttribute(hConsole, (COLOR_BLUE << 4) | COLOR_LTWHITE);
PrintText(" ");
}
PrintText("\n");
}
// wait for user input before closing
SetConsoleTextAttribute(hConsole, (COLOR_BLUE << 4) | COLOR_LTWHITE);
PrintText(" Fore\n\n Press enter to quit...");
getchar();
return 0;
}