NEED HELP WITH IMPORTANT PROJECT PLEASE

Hello, I was to make a post office management system for my school project and it is working perfectly, but now i want to decorate it and add some borders to the text it printed out using graphics.h.
I tried to add the border using rectangle function but it is showing like this
http://imgur.com/1KDErde
Please can somebody help me
I am a beginner so please easy code so that i can understand
Thank you
closed account (1vf9z8AR)
share the code that you have used.
@XXpoomaanXX
Here's a bit of a program I wrote years ago, but modified it abit, to have it print the menu you had. I don't have color in this version, but do in other improved versions I've written since. It's best though, to get your program running without color at the start, til you get everything the way you like, then add in colors for looks.

Hope this is what you were looking for..

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
#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 
       //                    a way to clear just a portion of the screen.
	//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.
	
	char holder;
	Draw(1, 2, 1, 76, 23, 0, 0);  // Box, 1 line, around screen
	Draw(2, 12, 4, 56, 16, 1, 3); // Box, 2 lines, around screen
	gotoXY(30, 5, "Welcome to E-Post Office");
	gotoXY(30, 7, "What would you like to do?");
	gotoXY(30, 10, "1 - Add New Record");
	gotoXY(30, 11, "2 - Display All Records");
	gotoXY(30, 12, "3 - Search Record");
	gotoXY(30, 13, "4 - Delete Record");
	gotoXY(30, 14, "5 - Update Record");
	gotoXY(30, 15, "0 - Exit");
	gotoXY(30, 17, "Enter your choice _\b");
	cin >> holder;
	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);
	}
}
@whitenite1
Sorry, i dont understand half of this stuff i am very new to c++
please if you can write up an easy code or just help me remove that grey portion, that would be very helpful
@XXpoomaanXX

help me remove that grey portion


What portion is that? If you're referring to the shadow on the inner box, just change the 3 to a 0 on line 28 in my code. Lines 16 to 24, tell you what the numbers mean when calling the draw function.
@whitenite1
What portion is that?

all the grey part on the right of the text

and like i said, i am very new,i don't even have windows.h
can you tell me how can i make border with graphics.h only please
my code is already very long (1500 lines) and dont want to increase it too much
@XXpoomaanXX

can you tell me how can i make border with graphics.h only please


Sorry, no. I use Microsoft Visual Studio 2012, and it does not use graphics.h.

Anyway, if you can't use any of the code I showed, or want to, you'll have to find someone that knows about your graphics.h and ways to use it. I did the best I know how, to be of help. Good luck on your future endeavors.

@whitenite1
Thank you very much for your assistance
Hello XXpoomaanXX,

To start with this post might be useful: http://www.cplusplus.com/forum/beginner/218646/

I have two functions that would be useful, but I will have to work with them to see if they will do what you want.

Hope that helps,

Andy
Hello XXpoomaanXX,

I have not tried whitenite1's program yet, so I am not sure what you could use, but it looks interesting.

I played with some functions I use and came up with this:

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
#include <iostream>
#include <string>
#include <Windows.h>
#undef max  //  Needed when I include Windows.h.
#include <limits>  // Needed for next to as line.

// These could be put in a header file if you want.
#define NORMAL SetColor(7)
#define GREEN SetColor(10)
#define BLUE SetColor(11)
#define PINK SetColor(13)
#define YELLOW SetColor(14)
#define WHITE SetColor(15)

void SetColor(int forground = 7, int background = 1);
void GotoXY(short x, short y);
void MsgBox(short row, short col, int nuLines);

//******************************************

void MsgBox(short row, short col, int numLines)
{
	int width{ 59 };

	GotoXY(row, col);
	PINK;
	std::cout << static_cast<char>(0XC9);

	for (int lp = 0; lp < width; lp++) std::cout << static_cast<char>(0xCD);

	std::cout << static_cast<char>(0XBB);

	for (size_t lc = 0; lc < numLines; lc++)
	{
		GotoXY(++row, col);
		std::cout << static_cast<char>(0XBA) << "  ";
		for (size_t lc = 0; lc < width - 2; lc++)
		{
			std::cout << " ";
		}
		PINK;
		std::cout << static_cast<char>(0XBA);
	}

	GotoXY(++row, col);
	PINK;
	std::cout << static_cast<char>(0XC8);
	for (size_t lp = 0; lp < width; lp++) std::cout << static_cast<char>(0xCD);
	std::cout << static_cast<char>(0XBC);


}  // End function MsgBox()

void GotoXY(short x, short y)
{
	COORD p = { y, x };
	SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), p);
}

void SetColor(int forground, int background)
{
	WORD consoleColor;
	HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
	CONSOLE_SCREEN_BUFFER_INFO csbi;

	if (GetConsoleScreenBufferInfo(hStdOut, &csbi))
	{
		//consoleColor = (csbi.wAttributes & 0xF0) + (ColorPicker & 0x0F);
		consoleColor = (forground + (background * 16));
		SetConsoleTextAttribute(hStdOut, consoleColor);
	}
}  //  End SetColor()

int main()
{
	int width{ 59 };

	std::cout << "\n  ";


	MsgBox(2, 2, 15);  // row, col, number of lines for the box.
	SetColor(0, 14);  // <--- Requires a forground and background number. Blank for defaults. This is Black on Yellow.
	GotoXY(4, 25);  // <--- Could use a variable like row++ and col.
	std::cout << " Test menu "; // <--- A space before and after text may make it look better.

	GotoXY(23, 2);
	std::cout << "\n\n\n\n Fin Press any key to continue -- > ";
	std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');  // <--- Needs limits header file.

	return 0;
}


I found that starting in column 2 I could only have a width of 59 in the "MsgBox" function. I have not figured out why I can not print to the whole width of the screen. So far what I have figured out is that part of the problem has to do with the point size of the font I am using. The font its-self should be a fixed width font. Maybe someone else has an idea.

Line 83 and 84 could be repeated as many times as you need for menu items.

Hope that helps,

Andy
@Handy Andy

Change your lines # 23 and 76, from int width{ 59 }; to int width = ??;
Use whatever number you want for the two '??". I used 110, and got a very wide box.
@whitenite1.

I tried that and it did not work. As I said I found that starting in column 2 I could only have a width of 59. If I changed the point size of the font I could get a wider line. For me anything over 59 will finish on a second line due to the setup I have for the console window and the point size I use.

@XXpoomaanXX,

It would help to know where you found your "graphics.h" file from. Put the full link on its own line for it to be clickable. It needs to start with "http:/...".

It would also help to know what IDE you are using the "graphics.h" file with.

Looking at your example screen I would guess that you may have to use a "gotoxy" function to print your menu choices instead of using "\n" to end a line before printing the next line.

Hope that helps,

Andy
Last edited on
Topic archived. No new replies allowed.