Click here to Skip to main content
15,881,600 members
Please Sign up or sign in to vote.
1.00/5 (1 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: http://www.alt-codes.net/[^]

Sorry patterns appear distorted in preview(dont know why), but you can guess what I want.
1)
╔══════════════════╗   
║                  ║
║                  ║
║                  ║
║                  ║
║                  ║
╚══════════════════╝


2)

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


and so on.....

[edit]Code block added - OriginalGriff[/edit]
Posted
Updated 9-Feb-13 22:41pm
v3
Comments
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!
Sergey Alexandrovich Kryukov 10-Feb-13 8:43am    
It simply makes no sense. Why doing all that?
—SA
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.
Sergey Alexandrovich Kryukov 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.
—SA

1 solution

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.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900