Click here to Skip to main content
13,552,835 members
Rate this:
Please Sign up or sign in to vote.
See more:
I was thinking of printing some border design at the screen borders(see below) in c++ using graphics (using alt codes) but don't know how to. Please help.

examples :

Alt code used:[^]

Sorry patterns appear distorted in preview(dont know why), but you can guess what I want.
║                  ║
║                  ║
║                  ║
║                  ║
║                  ║


░░ ░░
░░ ░░
░░ ░░
░░ ░░
░░ ░░

and so on.....

[edit]Code block added - OriginalGriff[/edit]
Posted 9-Feb-13 22:20pm
Updated 9-Feb-13 22:41pm
OriginalGriff 10-Feb-13 4:44am
Your preview looks distorted because HMTL suppresses multiple spaces - I have used a code block to force the system to preserve them on the first one.
Unfortunately, if I add the pre tags to teh second example, the border itself disappears - so you will have to live with that!
prerit-datta 10-Feb-13 4:45am
Thanks for editing anyway!
SAKryukov 10-Feb-13 8:43am
It simply makes no sense. Why doing all that?
prerit-datta 10-Feb-13 9:02am
I'm making a school quiz project in c++. The screen gets refreshed and this border(design) appears along with a new question every time a user answers one.
SAKryukov 10-Feb-13 9:04am
What, a school quiz requires a frame?!
And if this is a quiz, why are you asking a question? This is called cheating.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

I'm assuming you're working on a Console Application on Windows? If not then this will be completely wrong.
The console is a relatively small fixed sized grid 80x25 or perhaps 120x43 depending on how you've configured it.
If you're going to paint whole console screens then I would set up one or more 80 x N arrays in memory and write a 'blitter' function to write an array to the screen all in one go.
Win32 functions like FillConsoleOutputCharacter and Fill ConsoleOutputAttribute will help you there.
The trick to getting useful symbol characters out of which you can construct boxes and borders to appear is in setting the right Code Page. A Code Page is an old fashioned way of doing internationalisation on the console, essentially it swaps the extended ASCII character set (chars>127) for one containing accented characters or cyrillic or whatever. To get the symbols you want I think it's code page 852 you need which is an IBM character set definition from the early days of the PC. You'll have to check. The SetConsoleCP function will enable you to change it.
If you're going to be doing a lot of this sort of thing and don't want to write it all yourself from scratch you might consider searching for the pdcurses library, a Windows port of ncurses which is essentially a 'windowing' library for the console. It will have boxes, menus, popups, buttons etc. ncurses is part of the Linux Standard Base.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.180515.1 | Last Updated 10 Feb 2013
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100