Changing output text colour in a console window?

DrEvil

FCRI Associate!
Reaction score
111
I've been working on a text based game in c++ (Console)
And well.... All the text is white.
I've read up ways of being able to change the output text colour through:
'SetConsoleTextAttribute(hConsole, k);'
where hConsole is the handle of the window and k is a hex number (0-255,0xFF) (the first char would be the text background and the second is the text colour)
the hex value has a maximum of 16 colours.(for background and text colour)

I am wondering if there is a way to set a custom colour of text through a UInt32? Where the RGB can be modified on its own?

e.g. SetTextColour(0x9564fa); Would give me a nice purple... ;)
and also a function for the background colour?


I'm just curious as the 16 colours (including black :mad:) are just not the colours I find useful :cool:
 

UndeadDragon

Super Moderator
Reaction score
447
I think the reason of the limited text colours is because it is just a console application. If you want to use more advanced things such as extended colours I would recommend into looking into a very basic console-like GUI.
 

DrEvil

FCRI Associate!
Reaction score
111
That's basically all I have for changing the colours :p
//colorattribute = foreground + background * 16
Is the hexadecimal I was talking about above.
Where 0xF9 would relate to 16*15(background) + 9(text).

But as UndeadDragon said, it's probably because it is actually just a console application and doesn't need a multitude of different colours.

I'l just stick to using the 16 colours :D
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top