Just wondering the best way to do font color and background color. Finished my class in c++, but I want to sharpen my skills, but I don't know what else to make.
the standard language does not support color, you need a library for that. Which is fine: you can learn how to use a library and link it in etc ... try ncurses for this.
Font may not be doable at all. The console is often one font, and if you change it, you just change all the letters at once, like notepad would do.
Adding color to the console is cool and all, but if you're really trying to "sharpen your skills", simply adding a few coloring commands isn't really doing that, in my opinion.
I would rather start designing a somewhat-complex program, something you would be interested in creating and using.
GUI for all major operating systems is typically done with a framework like Qt or WxWidgets (the result can then run on Windows, Linux, MAC, etc.)
@Cjigsaw...and that's likely where you are headed anyway.
Stroustrup points out in various discussions and lectures that modern students really need to "see GUI" for their own interests. He realized that as a teacher, modern students just lose too much interest if their programs don't have GUI. In his books he uses FLTK, because it is "simple" - too simple, really, but simple.
I've used WxWidgets on a lot of products and can recommend it. Qt may be perceived to be better, but not by much. It also has some minor licensing concerns that WxWidgets does not.
It is an important study, and one you're not expecting.
You've focused on text color and font selection. No doubt that is motivated by using a GUI based computer. However, GUI applications have at the very least one more important difference in how they are made compared to the console applications you're familiar with at this point. They are event driven. You've never seen that from the inside before.
That said, though you have completed a C++ course, I'm aware that your next phase in the study of the language is about classes (objects), inheritance, virtual functions.
I highly recommend that you find a copy of Stroustrup's C++ Principles and Practice. That will walk you through what you really need at this point.
Being a self-taught (badly) programmer hobbyist I kinda already knew the bare minimum basics of GUI frameworks, having played around a bit with FLTK courtesy of Stroustrup's book and glanced at the webpages of WxWidgets and Qt.
None of it all really sparked an interest for me. As bloated and over-burdensome as Win32 desktop API programming can be I'm somewhat comfortable with how it is supposed to work.
Being self-taught Win32/DirectX has the slight advantage of having numerous Learn How To books available. All rather mediocre, but make for somewhat of a decent overview.
If you are like me, you have finished what you were working on and want to do something fun.
Several years ago I found that when the lighting went dim in the evening that white on black was hard to read and that white on dark blue was easier to read.
Doing some research I found that the old DOS way of changing the colour was no longer available and went looking for a C++ way and found this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
void SetColor(int foreground = 7, int background = 1);
void SetColor(int foreground, int background)
{
WORD consoleColor;
HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO csbi;
if (GetConsoleScreenBufferInfo(hStdOut, &csbi))
{
//consoleColor = (csbi.wAttributes & 0xF0) + (ColorPicker & 0x0F);
consoleColor = (foreground + (background * 16));
SetConsoleTextAttribute(hStdOut, consoleColor);
}
} // End SetColor()
In the prototype I set a default foreground and background colour. This allows you to use SetColor(); to reset to the defaults. using just one number in the parameters will use the default background colour.
The advantages are that you can change the colour of each letter in a word, the colour of one or more words, a whole paragraph or even the whole screen if you follow the call to the function with some way of clearing the screen.
The biggest disadvantage is the it is not easy to use if you have many changes to make.