Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C 

C++ - Changing CMD background colour?

Not the text background but the actual whole console
My compiler is VS

I don't know if the system function has it, but I'd rather not use it
I've been looking everywhere I can :P
http://ss64.com/nt/color.html

Just use the system() function for it.

Example:

Code
system("COLOR 83");
(Apr 3, 2016 09:40 AM)Remix Wrote:  http://ss64.com/nt/color.html

Just use the system() function for it.

Example:

Code
system("COLOR 83");

Alright, read some posts on text colouring and some guy said system is bad and shouldn't be used - it's not the way to learn C++
(Apr 3, 2016 10:09 AM)Cough Wrote:  Alright, read some posts on text colouring and some guy said system is bad and shouldn't be used - it's not the way to learn C++

Why don't you ask that guy how to do it then?
Or why didn't he explained it?

Well.
Sure, the system function is shit but for basic coloring it's not that bad.
Anyways maybe you want to use the windows api:

Code
HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(console, 3);
(Apr 3, 2016 10:18 AM)Remix Wrote:  Why don't you ask that guy how to do it then?
Or why didn't he explained it?

Well.
Sure, the system function is shit but for basic coloring it's not that bad.
Anyways maybe you want to use the windows api:

Code
HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(console, 3);

Was on another site I managed to find, didn't really want to sign up.
System function seems simple but you can't change the background on its own?
(Apr 3, 2016 10:30 AM)Cough Wrote:  Was on another site I managed to find, didn't really want to sign up.
System function seems simple but you can't change the background on its own?

What do you mean with "on its own"?
You will have to use Console Buffers for this to get the size of the Window, and then use the SetConsoleScreenBufferInfoEx() to set the color for that buffer. Grabbing the console buffer info can be done with the GetConsoleScreenBufferInfoEx() function.
Getting Started: C/C++
[C/C++/.NET/x86 ASM - Automation Programmer]


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Shell] by Galnah55Jan 25, 2019 08:35 PM 5 219 Jan 25, 2019 08:35 PM
Last Post: AdHoc 1920
[Python] by SkidyMay 2, 2017 04:21 AM 13 447 May 2, 2017 04:21 AM
Last Post: Skidy
[C#] by Thoma$Aug 11, 2016 11:52 AM 12 265 Aug 11, 2016 11:52 AM
Last Post: +Haze