Archived

This topic is now archived and is closed to further replies.

c++ question

Recommended Posts

blooper    122
I''m relatively new to C++ and I had a question. In the command prompt is there a way to make it so everything remains static/in place instead of scrolling? Also I was wondering about coloring letters (I don''t know if it makes a difference but I have XP''s command prompt not reg DOS). I''m really more concerned with the scrolling issue though, thanks for your time.

CONIO.h

Share on other sites
blooper    122
Thanks! Anywhere I can find a good tut on it...? (Sorry about the newbie sounding garbabge but I''m unfortuneately in a bit of a ruch). Many thanks ahead of time.

Share on other sites
Jeff D    122
Well I can help with coloring the text, but the scrolling is an issue I would have to do myself. Her goes with the coloring.

You need this line

#include < windows.h >

in that header file there is 2 things you need to use this:

HANDLE H_OUTPUT = GetStdHandle(STD_OUTPUT_HANDLE);

You need that to do colors. Then you make need to do this:

SetConsoleTextAttribute(H_OUTPUT, FOREGROUND_RED);
cout << "Hello World";

Now there is six color attributes they are:

FOREGROUND_RED
FOREGROUND_BLUE
FOREGROUND_GREEN
BACKGROUND_RED
BACKGROUND_BLUE
BACKGROUND_GREEN

The FOREGROUND colors affect the symbol, while the BACKGROUND colors affect behind the symbol.

Now you can do this:

SetConsoleTextAttribute(H_OUTPUT, FOREGROUND_RED | FOREGROUND_GREEN | BACKGROUND BLUE);

That will make orange lettering on blue.

The '|'s, I wont go into details, but if you want orange you have to mix up FOREGROUND_RED and FOREGROUND_GREEN. The '|' tells it to use that.

Try this:

  #include < windows.h >#include < iostream >using namespace std;int main(){ HANDLE H_OUTPUT = GetStdHandle(STD_OUTPUT_HANDLE); SetConsoleTextAttribute(H_OUTPUT, FOREGROUND_RED | FOREGROUND_GREEN | BACKGROUND_BLUE); cout << "Hello!";}

I hope I helped

Jeff D

Suffered seven plagues, but refused to let the slaves go free. ~ Ross Atherton

Edited by - Jeff D on February 6, 2002 9:46:56 PM

blooper    122
bump