[SOLVED]Load Bar -Creating a Square shape character

Jan 27, 2009 at 12:18am
Ok so in some programs I see in there console programs (when they are loading) they might use something in the lines of a bar. Question is what is the square character they use? As it counts up in blocks so it's normally a full colored gray square? Or at the least that's what I thought it was. Creating the bar to load is easy enough. I just want to make it look neat with one of these square blocks haha.

Cheers
Last edited on Jan 27, 2009 at 3:01am
Jan 27, 2009 at 12:21am
By looking it up as well I see it might possibly be they just fill up a space (" ") with the color gray etc. I'm just not sure how to actually do that?
Jan 27, 2009 at 12:48am
You could also try these extended ASCII characters:

▒(177), ▓(178), or █(219)
Jan 27, 2009 at 12:51am
Damn thats what I'm looking for but they come up as "?" -
warning C4566: character represented by universal-character-name '\u2593' cannot be represented in the current code page (1252)
Jan 27, 2009 at 1:17am
Trying all the things I can find like it - but they are all getting the same error as above. Is there a way I can in a sence - Include the form of characters or define them or anything like that?
Jan 27, 2009 at 1:45am
All good, figured it out with bar = bar + (char)219;
Jan 27, 2009 at 2:06am
Keep in mind that that only works on Windows, so just changing the background color (with SetConsoleTextAttribute() ) would work.

If you really want to get fancy, you can increase the granularity with (char)221 to fill half a square.

Have fun!
Jan 27, 2009 at 2:20am
Hmm I'm using http://www.cdrummond.qc.ca/cegep/informat/Professeurs/Alain/files/ascii.htm at the moment for all the different characters. But how exactly do you mean to use the half fill? You referring to changing the color of the string and use the (char)221 - so it would show half the color breaking through?
Jan 27, 2009 at 2:24am
Ok so I'm using (char)221 now but. How exactly do i Get this to work:
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), ...?);
What do I put in the "...?" Section I've never used one of those before?
Jan 27, 2009 at 2:29am
Oh wait hang on say I use something basic like: SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN); Is there anything else fancy I can do to it? Make it say multicolored or something? At the moment its the background is black and foreground is green. Anyway of changing the background of just that string that's being displayed?
Jan 27, 2009 at 2:36am
Hmm, is it something like this that you mean - This is kind of like and ugly pretty haha. Is it possible to mix the colors?
Jan 27, 2009 at 2:44am
Sorry about all the posting, just finding this a nifty Function. SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), (FOREGROUND_BLUE + BACKGROUND_GREEN)); Ok so I like how that looks but once its finished. How do I turn the Back and Fore Ground into its original colors?
Jan 27, 2009 at 3:01am
All is good - thanks for the help Duoas.

1
2
3
4
#define WHITE 0x000F
#define BLACK 0x0000

SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), (WHITE + BLACK));


I just used that to make it a nice white. Cheers for the help.

Thanks,
Myth.
Jan 27, 2009 at 5:27am
Also, you can use the edit button to add stuff to your old posts ^^
Jan 27, 2009 at 9:49am
Haha yeah I know, just got a little posting happy there :D
Topic archived. No new replies allowed.