Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ graphics
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 9-Feb-13 22:20pm
Edited 9-Feb-13 22:41pm
v3
Comments
OriginalGriff at 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 at 10-Feb-13 4:45am
   
Thanks for editing anyway!
Sergey Alexandrovich Kryukov at 10-Feb-13 8:43am
   
It simply makes no sense. Why doing all that?
—SA
prerit datta at 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 at 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

Rate this: bad
good
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.
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 279
1 Maciej Los 168
2 George Jonsson 154
3 Sarvesh Kumar Gupta 130
4 Dave Kreskowiak 130


Advertise | Privacy | Mobile
Web02 | 2.8.140709.1 | Last Updated 10 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid