ADDING BORDER

Dec 5, 2011 at 12:38pm
Hi

anybody help me here how can i put border on my console app..
when my program run the window automatically fullscreen.. if possible transparent border..

thanks in advance.
Dec 5, 2011 at 1:15pm
I don't believe that it is possible to customize the console from a program as you said
Dec 5, 2011 at 1:47pm
i saw one doing this but i cant understand the code that they use..

here's the link
http://cboard.cprogramming.com/attachments/cplusplus-programming/589d1015084435-my-best-cplusplus-console-game-games.zip

Dec 5, 2011 at 1:47pm
The borders are not transparent, but you can have a one or two line box frame, with or without shadows, with this program. Hopefully, you can use the parts you need you create your own program.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
// Scrolling Text 2.cpp : Defines the entry point for the console application.

#include <stdafx.h> // Used with MS Visual C++ 2008 ( or 2010 ) Express. Leave off
                                // if using a different compiler
#include <conio.h>
#include <iostream>
#include <string>
#include <windows.h>

using namespace std;

HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
COORD CursorPosition;

void gotoXY(int x, int y);
void gotoXY(int x, int y, string text);
void Draw(int style, int col, int row, int length,int amount, bool filled, int shadow );

int main(int)
{
	//           Draw routine
	//  first number = 1 for single line, 2 for a double lines
	// second number = column's across
	//  third number = row's down
	// fourth number = box total length
	//  fifth number = box total height
	//  sixth number = 0 for not filled, 1 for filled 
	//seventh number = 0 for no shadow, 1 for a light shadow, 2 for medium shadow, 3 for a dark shadow and 4 for a solid shadow.

	string PressKey = "- Programmed by whitenite1 - Added flashing box frame on September 14th, 2011 - Press any key to end program...";
	int x, y, len, frame;
	y = 1;
	frame = 2;
	char holder;
	Draw(1,2,1,76,23,0,0);  // Box, 1 line, around screen
	Draw(2,12,4,56,16,1,4); // Box, 2 lines, around screen
	Draw(1,28,6,25,3,0,2);  // Box, 1 line,  for Title
	gotoXY(30,7,"Scrolling Text Demo 2");
	Draw(2,23,13,36,3,0,2); // Box for moving text
	len = PressKey.length();
	do
	{
		gotoXY( 25,14);
		for (x=0;x<32;x++)
			cout << PressKey[x];  // scrolling the string called PressKey
		holder = PressKey[0];
		for ( x=0;x<len;x++)
			PressKey[x] = PressKey[x+1];
		PressKey[len] = holder;
		Sleep(120);
		Draw(frame,23,13,36,3,0,0);
		y++;
		if (y>5)
		{
			Draw(frame,28,6,25,3,0,0);
			frame--;
			y=0;
		}
		if ( frame==0)
			frame=+2;
	} while (_kbhit() == '\0' );
	gotoXY(25,14,"            Good-Bye            ");
	gotoXY(25,14);
	Sleep(2500);
	return 0;
}

void gotoXY(int x, int y) 
{ 
	CursorPosition.X = x; 
	CursorPosition.Y = y; 
	SetConsoleCursorPosition(console,CursorPosition); 
}

void gotoXY(int x, int y, string text) 
{ 
	CursorPosition.X = x; 
	CursorPosition.Y = y; 
	SetConsoleCursorPosition(console,CursorPosition);
	cout << text;
}

void Draw(int style, int col, int row, int length,int amount, bool fill, int sw )
{
	// Draws a 1 or 2 line box 
	int a;
	if ( sw >4)
		sw = 4;
	style=(style-1)*6;
	char box[12];
	char shdw[5];
	
	box[0] = '\xDA';//  ┌
	box[1] = '\xBF';//  ┐
	box[2] = '\xC0';//  └
	box[3] = '\xD9';//  ┘
	box[4] = '\xB3';//  │ 
	box[5] = '\xC4';//  ─
	box[6] = '\xC9';//  ╔ 
	box[7] = '\xBB';//  ╗
	box[8] = '\xC8';//  ╚
	box[9] = '\xBC';//  ╝
	box[10] = '\xBA';// ║
	box[11] = '\xCD';// ═
	shdw[1] = '\xB0';// ░
	shdw[2] = '\xB1';// ▒
	shdw[3] = '\xB2';// ▓
	shdw[4] = '\xDB';// █
	char tl,tr,bl,br,side,edge,shadow;
	tl = box[style];
	tr = box[style+1];
	bl = box[style+2];
	br = box[style+3];
	side = box[style+4];
	edge = box[style+5];
	shadow = shdw[sw];
	string Line(length-2,edge);
	string Shadow(length,shadow);
	string Fill(length-2, ' ');
	gotoXY(col,row);
	cout << tl << Line << tr;
	for (a = 1; a <amount-1;a++)
	{
		gotoXY(col,row+a);
			cout << side;
		if  (fill)
			cout << Fill;
		else		
			gotoXY(col+length-1,row+a);
		cout << side;
		if (sw)
			cout << shadow;
	}
	gotoXY(col,(amount+row)-1);
	cout << bl << Line << br;
	if (sw)
	{
		cout << shadow;
		gotoXY(col+1,row+amount , Shadow );
	}
}
Last edited on Dec 5, 2011 at 1:50pm
Dec 5, 2011 at 2:05pm
how can i put the content of my program inside the line?
i try to get the one line border..

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#include <conio.h>
#include <iostream>
#include <string>
#include <windows.h>

using namespace std;

HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
COORD CursorPosition;

void Draw(int style, int col, int row, int length,int amount, bool filled, int shadow );
void gotoXY(int x, int y);
void gotoXY(int x, int y, string text);
int main () {
	
Draw(1,2,1,76,23,0,0);  // Box, 1 line, around screen





  cout<<"\n\n\n\n\n\n\n";

  system("PAUSE");
}

void gotoXY(int x, int y) 
{ 
	CursorPosition.X = x; 
	CursorPosition.Y = y; 
	SetConsoleCursorPosition(console,CursorPosition); 
}

void gotoXY(int x, int y, string text) 
{ 
	CursorPosition.X = x; 
	CursorPosition.Y = y; 
	SetConsoleCursorPosition(console,CursorPosition);
	cout << text;
}

void Draw(int style, int col, int row, int length,int amount, bool fill, int sw )
{
	// Draws a 1 or 2 line box 
	int a;
	if ( sw >4)
		sw = 4;
	style=(style-1)*6;
	char box[12];
	char shdw[5];
	
	box[0] = '\xDA';//  ┌
	box[1] = '\xBF';//  ┐
	box[2] = '\xC0';//  └
	box[3] = '\xD9';//  ┘
	box[4] = '\xB3';//  │ 
	box[5] = '\xC4';//  ─
	box[6] = '\xC9';//  ╔ 
	box[7] = '\xBB';//  ╗
	box[8] = '\xC8';//  ╚
	box[9] = '\xBC';//  ╝
	box[10] = '\xBA';// ║
	box[11] = '\xCD';// ═
	shdw[1] = '\xB0';// ░
	shdw[2] = '\xB1';// ▒
	shdw[3] = '\xB2';// ▓
	shdw[4] = '\xDB';// █
	char tl,tr,bl,br,side,edge,shadow;
	tl = box[style];
	tr = box[style+1];
	bl = box[style+2];
	br = box[style+3];
	side = box[style+4];
	edge = box[style+5];
	shadow = shdw[sw];
	string Line(length-2,edge);
	string Shadow(length,shadow);
	string Fill(length-2, ' ');
	gotoXY(col,row);
	cout << tl << Line << tr;
	for (a = 1; a <amount-1;a++)
	{
		gotoXY(col,row+a);
			cout << side;
		if  (fill)
			cout << Fill;
		else		
			gotoXY(col+length-1,row+a);
		cout << side;
		if (sw)
			cout << shadow;
	}
	gotoXY(col,(amount+row)-1);
	cout << bl << Line << br;
	if (sw)
	{
		cout << shadow;
		gotoXY(col+1,row+amount , Shadow );
	}
}
Last edited on Dec 5, 2011 at 2:06pm
Dec 5, 2011 at 2:20pm
@nielcleo

Use the gotoXY() function. If you want a variable to be printed at the 7th column, 12th row, use, gotoXY(7,12);
And, if you want text written at that location, it's gotoXY(7,12,"Nielcleo"); As long as it is ONLY text, with no variables.
Dec 5, 2011 at 2:25pm
that's my problem :(

i have long codes containing switch and if else for a simple question and answer game..
im finished enhancing the console like having a full screen.. but encounter little problem its not nice to see the content align at the upper right corner of the LCD.. thats why im asking help to have a border on it to give space for all the text content

Dec 5, 2011 at 3:43pm
@nielcleo

You just have to add the gotoXY() where you want the text printed. Don't use endl or newline. '\n'
To clear the screen of previous data, use the Draw function with a '1' for the bool fill. I have a 5 question quiz program, and used the Draw function, and it looks great. Hope this helps you.

Post the code you're having problems with, and I can better help with it.
Last edited on Dec 5, 2011 at 3:45pm
Dec 5, 2011 at 4:10pm
here's my source code...

i uploaded it mp.txt because its too long.. because of the switch
sorry that's the a newbie source code :(
here's the download link
http://www.qfpost.com/download.do?get=2bb498e95954b96f18b435618fe31a6c

i dont know where should i put it on.. to have a 1 line border.
Last edited on Dec 5, 2011 at 4:11pm
Dec 5, 2011 at 5:39pm
@nielcleo

Give me a little time, and I'll see what I can do with it.
Dec 6, 2011 at 5:24am
sure sir whitenite,

thanks in advance
Dec 6, 2011 at 6:37am
@nielcleo

Can you give me a personal email address to send the .cpp file? It's too big to post.
Dec 6, 2011 at 10:42am
@whitenite1

here sir, nielcleo@gmail.com
Dec 7, 2011 at 12:09am
@nielcleo

I tried emailing you at the above address, and it was returned to me as undeliverable. PM me and I'll send a reply to see if it works.
How were going to make a medium and difficult section of the quiz? I figured the four answer quiz could be medium, a three answer quiz, as easy and a five answer as difficult. Just an idea unless you had plans already.

Dec 7, 2011 at 6:47am
@whitenite1
same as the easy section but the question might be much difficult than the easy one..

try emailing here,
ncba01_cleo@yahoo.com

or try to upload here

http://www.quickfilepost.com/

thanks,
Dec 8, 2011 at 4:31am
@nielcleo

Did you get the email, I sent??
Dec 8, 2011 at 6:45pm
@whitenite1
yes i receive it thanks a lot for helping me :)

many many thanks
Topic archived. No new replies allowed.