A small text box for console based applications. It can be used as a help dialog box or showing the tips, hints in a game or as an information box. Its length and height can be changed.

#include <stdio.h>
#include <conio.h>
#include <string.h>

#define TITLE_LENGTH 20
#define TEXT_LENGTH 20

void make_textbox(struct textbox);
void draw_box(int left, int top,int width, int height);

struct textbox
{
	int left;
	int top;
	int width;
	int height;
	char title[TITLE_LENGTH+30];
	char text[TEXT_LENGTH+30];
};
void main(void)
{
	struct textbox aboutbox={10,3,62,15,"About Textbox Program CopyRight (c) 1999 by Muhammad Saqib."};
	struct textbox errorbox={20,7,40,9,"Warning Press Esc to Exit!"};
	_setcursortype(_NOCURSOR);
	textbackground(BLACK);
	clrscr();
	make_textbox(aboutbox);
	getch();
	textbackground(BLACK);
	clrscr();
	make_textbox(errorbox);
	getch();
	_setcursortype(_NOCURSOR);
}
void make_textbox(struct textbox box)
{
   textbackground(BLUE);
   textcolor(WHITE);
   draw_box(box.left,box.top,box.width,box.height);
   gotoxy(box.left+(box.width-strlen(box.title))/2-1,box.top);
   cputs(box.title);
   gotoxy(box.left+(box.width-strlen(box.text))/2-1,box.top+(box.height-1)/2);
   cputs(box.text);
}
 void draw_box(int left, int top, int width, int height)
 {
	int j;
	char string[81];
	window(left,top,left+width-1,top+height-1);
	clrscr();
	window(left,top,left+width-1,top+height);
 
	for(j=1;j<width-1;j++)
	string[j]='\xC4';
	string[width]='\0';
	string[0]='\xDA';
	string[width-1]='\xBF';
	gotoxy(1,1);
	cputs(string);
	string[0]='\xC0';
	string[width-1]='\xD9';
	gotoxy(1, height);
	cputs(string);
	for(j=2;j<height;j++)
	{
	gotoxy(1,j);
	putch('\xB3');
	gotoxy(width, j);
	putch('\xB3');
	}
	window(1,1,80,25);
 }