Sign in to follow this  
Servant of the Lord

Looking for a few console commands...

Recommended Posts

In the win32 console app, how do I make a single line italic or bold? And how do I make a certain line colored text? (Without changing the color of the entire console's text) If there is a simple line or two of code that explains how to do one of these, please post and explain it for me. If it is a huge thing, however, could you post a link? I'm using Dev C++, thanks. Oh, and I already know of the system("color 04"); thing, but I want to change just one line. Thanks again!

Share this post


Link to post
Share on other sites
Oberon_Command    6081
Making text in a console window italic or bold is impossible.

There's some Win32 API calls that do it. I think it's something like "SetConsoleTextAttribute" or something like that, but I don't really know, since I haven't used the console in a while.

Share this post


Link to post
Share on other sites
Ravyne    14300
I'm not sure about Italic or Bold, but IIRC the old conio.h C library is a lot more flexible than stdio or iostream. I know I've seen it used to set colors on specific text before.

EDIT: Scratch that, conio.h was more of a coincidence than anything else. I have seen specific text set to a color though.

Share this post


Link to post
Share on other sites
Quote:
Original post by dpadam450
about all you can do with consoles


Thanks. Any other sites anyone? Also, Drew_Benton gave me this awhile back and I've just remembered.


void SetColor(int textColor, int backGroundColor = 0)
{
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hConsole, (WORD)((backGroundColor << 4) | textColor));
}

Thanks Drew!


Still, anyone have a way to add italic or bold text to a console?

Share this post


Link to post
Share on other sites
Oberon_Command    6081
Quote:
Original post by Servant of the Lord
Still, anyone have a way to add italic or bold text to a console?


When I said that it's impossible, I wasn't joking or exaggerating. I meant it literally.

Sure, you can change the font, but it only changes the entire console, and AFAIK there's no way to do it from a running application (you CAN change the font by fiddling with the options on the console, but programs can't do it themselves).

If you want bolded/italic text and other fonts on Windows, you'll have to look into Windows GDI or some other graphics API, I'm afraid.

Share this post


Link to post
Share on other sites
Okay. I wasn't exactly needing bold text, I was just wondering whether it was possible. Would it be possible(for me) to make one? I figure, the current text is drawn to the screen somehow. If I could figure it out, I could create an option to allow for a second or third charactor set which I could switch in or out. Just wishful thinking I guess, but it would be good practice even if I fail.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this