How do i change backround color and text color?

This is a discussion on How do i change backround color and text color? within the C++ Programming forums, part of the General Programming Boards category; Well i found 1 way to change back round and text color but im running into problems doing it Code: ...

  1. #1
    Registered User
    Join Date
    Jun 2008
    Posts
    114

    How do i change backround color and text color?

    Well i found 1 way to change back round and text color but im running into problems doing it
    Code:
    #include <iostream>
    #include <windows.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <windows.h>
    #include "game.cpp"
    using namespace std;
    
    int main()
    {
        char choice;
        Sleep(100);
        printf("\n");
        system("Color 60");
        SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 6);
        printf("\t\t\t      By Nathan of awsometon\n");
        Sleep(100);
        printf("\n");
        Sleep(100);
        printf("\n");
        SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 4);
        printf("\t\t\t     [N]ew Game\n");
        printf("\t\t\t     [Q]uit\n");
        Sleep(100);
        printf("\n");
        Sleep(100);
        printf("\n");
        Sleep(100);
        printf("\n");
        Sleep(100);
        printf("\n");
        choice=toupper(getch());
        for(;;)
    But whenever i choose a number like 56 in the text attribute it changes the backround color in the blank spaces of the line were the text is how would i fix this also?

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Not quite sure what you are asking, but if you want full control of each character, then you could use WriteConsoleOutput, which allows you to specify attribute and character for each individual character.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21