Results 1 to 7 of 7

Thread: background color!!!

  1. #1
    Fanatic Member merhaba's Avatar
    Join Date
    Sep 02
    Location
    Istanbul,Bartin
    Posts
    599

    background color!!!

    hi



    Well I am new to C++ and I know little about C++ .All that I see
    is "a DOS window" Is there any small and simple program that I play with..
    for example ,lets first generate a random number and if number =10 let the
    background color of our page becomes green..
    This way I will get an idea of how C++ works...or any suggestion??
    thanks

  2. #2
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 02
    Location
    @ Opera Software
    Posts
    10,191
    Graphics is usualy not what you start with when it comes to C++ because C++ it self doesn't contain any GUI libs. You have to use external libs or API calls or what ever, and then you should know a bit about C++ first. Try to make some hello world apps, read up on about random numbers, and make more functions, then some classes, and stuff. Read the tutorials CornedBee have been so nice to write for us. And if you like it, then buy a book.

  3. #3
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 03
    Location
    USA, Maryland
    Posts
    4,981

    Re: background color!!!

    Originally posted by merhaba
    Well I am new to C++ and I know little about C++ .All that I see
    is "a DOS window" Is there any small and simple program that I play with..
    for example ,lets first generate a random number and if number =10 let the
    background color of our page becomes green..
    This way I will get an idea of how C++ works...or any suggestion??
    thanks
    It depends on what graphics interface you want to use. If you want to change the background color of a console window, then you have to color each line and it can get messy. I don't believe that would even color the entire window.

    Do you want to make an empty window with a color in it that changes? Do you want to change the background of a console program? Do you want to change the background color of a program you're working on? if so, what GUI are you using?

    We need more information to help you out but I agree with the suggestion already made. If you don't know much of C++, do the non-GUI stuff first and buy a book. Reading the tutorials here is also a good start.

  4. #4
    PowerPoster Halsafar's Avatar
    Join Date
    Jun 04
    Location
    Saskatoon, SK
    Posts
    2,339
    GUI "Graphics User Interface"

    Definitly is not the best place for you to start you new found task of tutoring yourself through C++.

    I would start with like suggested a hello app like, this one is a bit beefed up, I just wrote it now and tested it...so it should work.
    #include <iostream.h>

    PHP Code:
    int main()
    {
        
    bool bRunning true;
        
    int Choice 0;

        while (
    bRunning)
        {
            
    cout << "*******************" << endl;
            
    cout << "*Choice 1: (Hello)*" << endl;
            
    cout << "*Choice 2: (Exit) *" << endl;
            
    cout << "*******************" << endl << endl;

            
    cout << "Enter your choice: ";
            
    cin >> Choice;
            
    cout << endl << endl;

            if (
    Choice <= || Choice 2cout << "Invalid Selection!" << endl;
            else if (
    Choice == 1cout << "HELLO WORLD COMPLEX!!!!" << endl << endl << endl;
            else if (
    Choice == 2bRunning false;
        }

            
    cout << "Good-Bye!" << endl;

            return 
    0;

    Understand that, and then continue.
    "From what was there, and was meant to be, but not of that was faded away." - - Steve Damm

    "The polar opposite of nothingness is existance. When existance calls apon nothingness it shall return to nothingness." - - Steve Damm

    "When you do things right, people won't be sure if you did anything at all." - - God from Futurama

  5. #5
    Software Eng. Megatron's Avatar
    Join Date
    Mar 99
    Location
    Canada
    Posts
    11,287
    Familiarize yourself with the Set/GetConsoleTextAttribute for colour changes in the console.

  6. #6
    Software Eng. Megatron's Avatar
    Join Date
    Mar 99
    Location
    Canada
    Posts
    11,287
    Originally posted by Megatron
    Familiarize yourself with the Set/GetConsoleTextAttribute for colour changes in the console.
    The others are right though; familiarize yourself with the language, itself, before anything fancy.

  7. #7
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 03
    Location
    USA, Maryland
    Posts
    4,981
    Originally posted by Halsafar

    #include <iostream.h>
    Remember, in the C++ standard, the .h is gone and it should be just <iostream>. <iostream.h> will still work but isn't standard. Also, including <iostream> guarentees all functions, types, ect in iostream will be included but may not come from just iostream.h. Where as iostream.h may or may not include all functions, types, ect that iostream should have.

    I'm not sure how well I explained that one. Maybe I can find a decent article about it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •