Skip to main content
SNP-2025-0024
Home / Code Snippets / SNP-2025-0024
SNP-2025-0024  ·  CODE SNIPPET

Graphical C++ – My Nostalgia

Turbo C++ · Published: 2025-01-13 · debmedia
01
Problem Statement & Scenario
The Problem

GCPPFUNC.H

/* Almost complete header file for creating greatest graphical objects ever
using turbo c++ */

#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<stdlib.h>
#include<iostream.h>
#include<fstream.h>
#include<dos.h>
#include<graphics.h>
#include<alloc.h>
#include<process.h>
#include<time.h>
#include<fcntl.h>
#include<math.h>
#include<dir.h>
#ifndef min
#define min(n,m)  ((n) < (m) ? (n) : (m))
#define max(n,m)  ((n) > (m) ? (n) : (m))
#endif

#define Esc 0x1b

#define ON 1
#define OFF 0
#define CRITICAL 1
#define QUESTION 2
#define EXCLAMATION 3
#define INFORMATION 4
#define THREE-D 1
#define FLAT 0
#define OFF 0
#define ON 1

extern int x=0,y=0,button=0,loopmain=1;
union REGS i,o;
struct SREGS s;

	/* Declaration area for all functions implimented here */
void graph();
void svga();
void highgraph();
int Val(char *);
char* Str(int);
char* Today();
char* Now();
char* Cwd();
void Print(int,int,char*);
void Vprint(int,int,char*);
void initmouse();
void showmouse();
void hidemouse();
void pointer(int pt=1);
int inkey();
int getscan();
void getmouse(int &button,int &x,int &y);
void setmouse(int x,int y);
void getmousepos(int *button,int *x,int *y);
void restrictmouse(int,int,int,int);
void mouseptr(int mark[50],int xstart,int ystart);
void getclick(int,int,int [][5]);
int getlink(int,int,int [][5]);
void invertcolors(int,int,int,int);
void activate(int,int,int,int,int,int [][5],int);
void back(int x1=0,int y1=0,int x2=0,int y2=0,int mode=0,char *file="tempfl.dat");
void sel(int,int,int,int,int);
void select(int,int,int,int,int);
void select_with_color(int,int,int,int,int);
void deselect_with_color(int,int,int,int,int);
void say(char *text="",char *title="");
int confirm(char *text="",char *title="");
char* intext(int,int);
void openwindow(int x1=1,int y1=1,int x2=638,int y2=478,char text[]="",int fillst=1,int titlecolor=1,int darkshade=8,int lightshade=15,int normalshade=7);
void openwindow2(int x1=1,int y1=1,int x2=638,int y2=478,char text[]="",int fillst=1,int titlecolor=1,int darkshade=8,int lightshade=15,int normalshade=7);
void buttonon(int,int,int,int,char *,int);
void image(int,int,int,int,char *);
void iconbtn(int,int,int,int,char *,int,int [][5],int);
void cmdbtn(int,int,int,int,char *,int,int,int [][5],int);
void buttoneffect(int,int,int,int);
void buttonclick(int,int,int,int);
void initaddons(char *dir="");
char* textfield(int,int,int);
void checkbox(int,int,int);
void progressbar(int,int,int,int);
void menu(int,int,char*,int,int);
int activemenu(int,int,char *,int,int);
void marquee(char *,int,int,int,int);
void pressbtn(int,int [][5]);
void liftbtn(int,int [][5]);
void endgui();
void getstr(int,char *);
int cur(int);
void isigraph(char *,int);
void getpassword(char *,char *,int s);
char* inputbox(char *,char *,int);
void MsgBox(char*, char*, int);
void MsgBox(char*,char*);
void MsgBox(char*);
void popmenu(int,int,int,int);
void combolist(int,int,int,int);
int mymenu(int,int,char *[],int,int);
int popupmenu(int,int,char *[],int,int);
void mybutton(int,int,int,int);
void textarea(char *,int,int,int);
void load_icon ( char *,int,int);
int Hue(int,int,int,int,int,int);

int md=2;
// return the desired mode
int huge Mode() { md++;return(md);}
int hg=3;
// return the desired mode
int huge mode() { hg++;return(hg);}
unsigned char icon_image[40][32] ;

struct ColorValue
{
    unsigned char Rvalue, Gvalue, Bvalue; //This structure have RGB values.
};

typedef struct ColorValue VGAPaletteType[256]; //ColorValue declared as VGAPaletteType[256] with all 256 colors.

int xasp, yasp;


void graph()
{
	int gd=VGA,gm=VGAHI;
	initgraph(&gd,&gm," ");
}

void svga()
{
	installuserdriver("SVGA256",Mode);
	int gd=DETECT,gm;
	initgraph(&gd,&gm," ");
}

void highgraph()
{
	installuserdriver("SVGA256",mode);
	int gd=DETECT,gm;
	initgraph(&gd,&gm," ");
}

int getscan(void)
{
	union REGS in,out;
	in.h.ah=0;
	fflush(stdin);
	while(!kbhit());
	int86(0x16,&in,&out);
	return(out.h.ah);
}

Val(char *str)
{
	int ret=atoi(str);
	return ret;
}

char* Str(int integer)
{
	char *ret;
	itoa(integer,ret,10);
	return ret;
}

char* Str(long int integer)
{
	char *ret;
	ltoa(integer,ret,10);
	return ret;
}

char* Today()
{
	char d[80];
	_strdate(d);
	return (d);
}

char* Now()
{
	char t[80];
	_strtime(t);
	return (t);
}

char *Cwd()
{
   char curdir[MAXPATH];
   strcpy(curdir, "X:\");
   curdir[0] = 'A' + getdisk();
   getcurdir(0, curdir+3);
   return(curdir);
}

void Print(int x,int y,char *print)
{
	setcolor(0);
	settextstyle(SMALL_FONT,HORIZ_DIR,4);
	outtextxy(x,y,print);
}

void Vprint(int x,int y,char *print)
{
	setcolor(0);
	settextstyle(SMALL_FONT,VERT_DIR,4);
	outtextxy(x,y,print);
}

void popmenu(int l,int t,int r,int b)
{
	setfillstyle(1,15);
	bar(l,t,r,b);
	setcolor(0);
	rectangle(l,t,r,b);
}

int mymenu(int xc1,int yc1,char *list[],int rows,int cols)
{
	hidemouse();
	int h=((rows*15)+10);
	int w=((cols*8)+10);
	setfillstyle(1,7);
	float *bck;
	float sz=imagesize(xc1,yc1,xc1+w,yc1+h);
	bck=new float[sz];
	getimage(xc1,yc1,xc1+w,yc1+h,bck);
	bar(xc1,yc1,xc1+w,yc1+h);
	popmenu(xc1,yc1,xc1+w,yc1+h);
	settextstyle(2,HORIZ_DIR,4);
	setcolor(0);
	for(int a=0;a<rows;a++)
		outtextxy(xc1+3,(yc1+2+(a*15)),list[a]);
	showmouse();
	getmouse(button,x,y);
	int lc=1,fnc=0,over=-1;
	delay(50);
	while(lc==1)
	{
		getmouse(button,x,y);
		for(int b=0;b<rows;b++)
		{
			if(button==1)
			{
				if((x>xc1+w)||(x<xc1)||(y>yc1+h)||(y<yc1))
				{
					fnc=0;lc=0;
				}
				else if((y>(yc1+(15*b)))&&(y<(yc1+(15*b)+15)))
				{
					fnc=b+1;lc=0;
				}

			}
			if(button==0)
			{
				if((y>(yc1+(15*b)))&&(y<(yc1+(15*b)+15)))
				{
					if((b!=over)||(over==-1))
					{
						if(over!=-1)
						{
							invertcolors(xc1+2,yc1+(15*over)+1,xc1+w-2,yc1+(15*over)+13);
						}
							invertcolors(xc1+2,yc1+(15*b)+1,xc1+w-2,yc1+(15*b)+13);over=b;
					}
					over=b;
				}
			}
		}
	}
	hidemouse();
	putimage(xc1,yc1,bck,COPY_PUT);
	showmouse();
	delete bck;
	return(fnc);
}

void load_icon ( char *file, int x, int y )
{
	int xx, yy ;
	FILE *fp ;

	/* open the specified icon file */
	fp = fopen ( file, "rb" ) ;

	/* if unable to open file */
	if ( fp == NULL )
	{
		outtextxy ( 160, 184, "Unable to open file! Press any key..." ) ;
		getch() ;

		/* shut down the graphics system */
		closegraph() ;
		restorecrtmode() ;
		exit ( 3 ) ;
	}

	/* read the bit image of icon */
	fread ( icon_image, sizeof ( icon_image ), 1, fp ) ;

	/* output the icon on the screen */
	for ( xx = x ; xx < x + 40 ; xx++ )
	{
		for ( yy = y ; yy < y + 32 ; yy++ )
			putpixel ( xx, yy, icon_image[xx - x][yy - y] ) ;
	}

	fclose ( fp ) ;
}

void combolist(int l,int t,int r,int b)
{
	setfillstyle(1,15);
	bar(l,t,r,b);
	setcolor(0);
	rectangle(l,t,r,b);
}

int popupmenu(int xc1,int yc1,char *list[],int rows,int cols)
{
	hidemouse();
	int h=((rows*15)+10);
	int w=((cols*8)+10);
	setfillstyle(1,7);
	float *bck;
	float sz=imagesize(xc1,yc1,xc1+w,yc1+h);
	bck=new float[sz];
	getimage(xc1,yc1,xc1+w,yc1+h,bck);
	bar(xc1,yc1,xc1+w,yc1+h);
	popmenu(xc1,yc1,xc1+w,yc1+h);
	settextstyle(2,HORIZ_DIR,4);
	setcolor(0);
	for(int a=0;a<rows;a++)
		outtextxy(xc1+3,(yc1+2+(a*15)),list[a]);
	showmouse();
	getmouse(button,x,y);
	int lc=1,fnc=0,over=-1;
	delay(50);
	while(lc==1)
	{
		getmouse(button,x,y);
		for(int b=0;b<rows;b++)
		{
			if(button==1)
			{
				if((x>xc1+w)||(x<xc1)||(y>yc1+h)||(y<yc1))
				{
					fnc=0;lc=0;
				}
				else if((y>(yc1+(15*b)))&&(y<(yc1+(15*b)+15)))
				{
					fnc=b+1;lc=0;
				}

			}
			if(button==0)
			{
				if((y>(yc1+(15*b)))&&(y<(yc1+(15*b)+15)))
				{
					if((b!=over)||(over==-1))
					{
						if(over!=-1)
						{
							invertcolors(xc1+2,yc1+(15*over)+1,xc1+w-2,yc1+(15*over)+13);
						}
							invertcolors(xc1+2,yc1+(15*b)+1,xc1+w-2,yc1+(15*b)+13);over=b;
					}
					over=b;
				}
			}
		}
	}
	hidemouse();
	putimage(xc1,yc1,bck,COPY_PUT);
	showmouse();
	delete bck;
	return(fnc);
}

void buttonpush(int x1,int y1,int x2,int y2,int state)
{
  if(state==1)
  {
  setcolor(15);
  line(x1,y1,x2,y1);
  line(x1,y1,x1,y2);
  setcolor(8);
  line(x2,y1,x2,y2);
  line(x1,y2,x2,y2);
  }
  else
  {
  setcolor(7);
  line(x1,y1,x2,y1);
  line(x1,y1,x1,y2);
  setcolor(7);
  line(x2,y1,x2,y2);
  line(x1,y2,x2,y2);
  }
}

void mybutton(int x1,int y1,int x2,int y2)
{
	setfillstyle(1,7);
	bar(x1,y1,x2,y2);
	setcolor(15);
	line(x1,y1,x2,y1);
	line(x1,y1,x1,y2);
	setcolor(8);
	line(x2,y1,x2,y2);
	line(x1,y2,x2,y2);
}

void textarea(char *list,int x1,int y1,int length)
{
	char str[40];
	setfillstyle(1,15);
	int right;
	right=x1+(8*length);
	bar(x1,y1,right,y1+15);
	buttonclick(x1,y1,right,y1+15);
	settextstyle(SMALL_FONT,HORIZ_DIR,4);
	setcolor(BLUE);
	outtextxy(x1+2,y1+1,list);
	setcolor(0);
}

void MsgBox(char text[])
{
	hidemouse();
	settextstyle(2,0,4);
	int width;
	width=textwidth(text)+20;
	int height=60;
	int xcol1=320-(width/2),xcol2=320+(width/2);
	int ycol1=240-(height/2),ycol2=240+(height/2);
	back(xcol1,ycol1,xcol2,ycol2,0);
	openwindow(xcol1,ycol1,xcol2,ycol2,"GcMsgBox");
	setcolor(0);
	buttonon(310,ycol2-17,330,ycol2-2,"OK",3);
	setcolor(0);
	outtextxy(xcol1+10,ycol1+20,text);
	showmouse();
	int lc=1;
	while(lc==1)
	{
		getmouse(button,x,y);
		if((x>310)&&(x<330)&&(y>ycol2-17)&&(y<ycol2-2)&&(button==1))
		{
			buttonclick(310,ycol2-17,330,ycol2-2);delay(50);
			lc=0;
		}
		if((x>xcol2-15)&&(y>ycol1+2)&&(x<xcol2-3)&&(y<ycol1+15)&&(button==1))
		{
			buttonclick(xcol2-15,ycol1+2,xcol2-3,ycol1+15);delay(50);
			lc=0;
		}
		if(inkey()==13)
		{ lc=0; }
	}
	hidemouse();
	back(xcol1,ycol1,xcol2,ycol2,1);
	showmouse();
	delay(90);
}

int MsgOkCancel(char text[],char title[])
{
	hidemouse();
	settextstyle(2,0,4);
	int xcol1,ycol1,xcol2,ycol2;
	int width;
	if(textwidth(text)>=textwidth(title))
	width=textwidth(text)+20;
	if(textwidth(title)>textwidth(text))
	width=textwidth(title)+20;
	int height=60;
	if(width>50)
	{
		xcol1=320-(width/2),xcol2=320+(width/2);
		ycol1=240-(height/2),ycol2=240+(height/2);
	}
	if(width<=50)
	{
		xcol1=320-50,xcol2=320+50;
		ycol1=240-(height/2),ycol2=240+(height/2);
	}
	back(xcol1,ycol1,xcol2,ycol2,0);
	openwindow(xcol1,ycol1,xcol2,ycol2,title);
	setcolor(0);
	buttonon(320-31,ycol2-17,320-1,ycol2-2,"OK",6);
	buttonon(320+1,ycol2-17,320+41,ycol2-2,"Cancel",3);
	sel(320+1,ycol2-17,320+41,ycol2-3,1);
	setcolor(0);
	outtextxy(xcol1+10,ycol1+20,text);
	showmouse();
	int lc=1,ans=0,opt=2,in;
	while(lc==1)
	{
		getmouse(button,x,y); //Get Mouse
		in=inkey();      //Get Keyboard.
		if((x>320-31)&&(x<320-1)&&(y>ycol2-17)&&(y<ycol2-2)&&(button==1))
		{
			buttonclick(320-31,ycol2-17,320-1,ycol2-2);delay(50);ans=1;
			lc=0;
		}       //OK button Click check.
		if((x>xcol2-15)&&(y>ycol1+2)&&(x<xcol2-3)&&(y<ycol1+15)&&(button==1))
		{
			buttonclick(xcol2-15,ycol1+2,xcol2-3,ycol1+15);delay(50);
			lc=0;
		}
			//Cancel button Click check.
		if((x>320+1)&&(x<320+41)&&(y>ycol2-17)&&(y<ycol2-2)&&(button==1))
		{
			buttonclick(320+1,ycol2-17,320+41,ycol2-2);delay(50);ans=0;
			lc=0;
		}
		if(in==13)
		{
			if(opt==1)
			{ans=1;}
			else if(opt==2)
			{ans=0;}
			lc=0;
		}
		if(in==75)
		{
			opt=1;
			sel(320-31,ycol2-17,320-1,ycol2-3,1);
			sel(320+1,ycol2-17,320+41,ycol2-3,0);
		}
		if(in==77)
		{
			opt=2;
			sel(320-31,ycol2-17,320-1,ycol2-3,0);
			sel(320+1,ycol2-17,320+41,ycol2-3,1);
		}
	}
	hidemouse();
	back(xcol1,ycol1,xcol2,ycol2,1);
	showmouse();
	delay(90);
	return(ans);
}

void MsgBox(char text[],char title[])
{
	hidemouse();
	int width;
	settextstyle(2,0,4);
	if(textwidth(text)>=textwidth(title))
	width=textwidth(text)+20;
	if(textwidth(title)>textwidth(text))
	width=textwidth(title)+20;
	int height=60;
	int xcol1=320-(width/2),xcol2=320+(width/2);
	int ycol1=240-(height/2),ycol2=240+(height/2);
	back(xcol1,ycol1,xcol2,ycol2,0);
	openwindow(xcol1,ycol1,xcol2,ycol2,title);
	setcolor(0);
	buttonon(310,ycol2-17,330,ycol2-2,"OK",3);
	setcolor(0);
	outtextxy(xcol1+10,ycol1+20,text);
	showmouse();
	int lc=1;               //x2-15,y1+2,x2-3,y1+15
	while(lc==1)
	{
		getmouse(button,x,y);
		if((x>310)&&(x<330)&&(y>ycol2-17)&&(y<ycol2-2)&&(button==1))
		{
			buttonclick(310,ycol2-17,330,ycol2-2);delay(50);
			lc=0;
		}
		if((x>xcol2-15)&&(y>ycol1+2)&&(x<xcol2-3)&&(y<ycol1+15)&&(button==1))
		{
			buttonclick(xcol2-15,ycol1+2,xcol2-3,ycol1+15);delay(50);
			lc=0;
		}
		if(inkey()==13)
		{ lc=0; }
	}
	hidemouse();
	back(xcol1,ycol1,xcol2,ycol2,1);
	showmouse();
	delay(90);
}

void MsgBox(char text[],char title[],int style)
{
	hidemouse();
	settextstyle(2,0,4);
	int width,height,xcol1,ycol1,xcol2,ycol2;
	if(style==0)
	{
		int width;
		if(textwidth(text)>=textwidth(title))
		width=textwidth(text)+20;
		if(textwidth(title)>textwidth(text))
		width=textwidth(title)+20;
		height=60;
		xcol1=320-(width/2),xcol2=320+(width/2);
		ycol1=240-(height/2),ycol2=240+(height/2);

		back(xcol1,ycol1,xcol2,ycol2,0);
		openwindow(xcol1,ycol1,xcol2,ycol2,title);
		setcolor(0);
		buttonon(310,ycol2-17,330,ycol2-2,"OK",3);
		setcolor(0);
		outtextxy(xcol1+10,ycol1+20,text);
		showmouse();
		int lc=1;
		while(lc==1)
		{
			getmouse(button,x,y);
			if((x>310)&&(x<330)&&(y>ycol2-17)&&(y<ycol2-2)&&(button==1))
			{
				buttonclick(310,ycol2-17,330,ycol2-2);delay(50);
				lc=0;
			}
			if((x>xcol2-15)&&(y>ycol1+2)&&(x<xcol2-3)&&(y<ycol1+15)&&(button==1))
			{
				buttonclick(xcol2-15,ycol1+2,xcol2-3,ycol1+15);delay(50);
				lc=0;
			}
			if(inkey()==13)
			{ lc=0; }
		}
		hidemouse();
		back(xcol1,ycol1,xcol2,ycol2,1);
		showmouse();
		delay(90);
	}

	else if(style==1)
	{
		int width;
		if(textwidth(text)>=textwidth(title))
		width=textwidth(text)+20+45;
		if(textwidth(title)>textwidth(text))
		width=textwidth(title)+20+45;
		height=60;
		xcol1=320-(width/2),xcol2=320+(width/2);
		ycol1=240-(height/2),ycol2=240+(height/2);

		back(xcol1,ycol1,xcol2,ycol2,0);
		openwindow(xcol1,ycol1,xcol2,ycol2,title);
		setcolor(0);
		buttonon(310,ycol2-17,330,ycol2-2,"OK",3);
		setfillstyle(SOLID_FILL,RED);
		fillellipse(xcol1+15,ycol1+30,10,10);
		setcolor(15);
		setlinestyle(SOLID_LINE,5,3);
		line(xcol1+10,ycol1+25,xcol1+20,ycol1+35);
		line(xcol1+20,ycol1+25,xcol1+10,ycol1+35);
		setlinestyle(SOLID_LINE,5,1);
		setcolor(0);
		outtextxy(xcol1+10+20,ycol1+25,text);
		showmouse();
		int lc=1;
		while(lc==1)
		{
			getmouse(button,x,y);
			if((x>310)&&(x<330)&&(y>ycol2-17)&&(y<ycol2-2)&&(button==1))
			{
				buttonclick(310,ycol2-17,330,ycol2-2);delay(50);
				lc=0;
			}
			if((x>xcol2-15)&&(y>ycol1+2)&&(x<xcol2-3)&&(y<ycol1+15)&&(button==1))
			{
				buttonclick(xcol2-15,ycol1+2,xcol2-3,ycol1+15);delay(50);
				lc=0;
			}
			if(inkey()==13)
			{ lc=0; }
		}
		hidemouse();
		back(xcol1,ycol1,xcol2,ycol2,1);
		showmouse();
		delay(90);
	}

	else if(style==2)
	{
		int width;
		if(textwidth(text)>=textwidth(title))
		width=textwidth(text)+20+45;
		if(textwidth(title)>textwidth(text))
		width=textwidth(title)+20+45;
		height=60;
		xcol1=320-(width/2),xcol2=320+(width/2);
		ycol1=240-(height/2),ycol2=240+(height/2);

		back(xcol1,ycol1,xcol2,ycol2,0);
		openwindow(xcol1,ycol1,xcol2,ycol2,title);
		setcolor(0);
		buttonon(310,ycol2-17,330,ycol2-2,"OK",3);
		setfillstyle(SOLID_FILL,RED);
		fillellipse(xcol1+15,ycol1+30,10,10);
		setcolor(15);
		settextstyle(SANS_SERIF_FONT,HORIZ_DIR,1);
		outtextxy(xcol1+12,ycol1+18,"?");
		settextstyle(SMALL_FONT,HORIZ_DIR,4);
		setlinestyle(SOLID_LINE,5,1);
		setcolor(0);
		outtextxy(xcol1+10+20,ycol1+25,text);
		showmouse();
		int lc=1;
		while(lc==1)
		{
			getmouse(button,x,y);
			if((x>310)&&(x<330)&&(y>ycol2-17)&&(y<ycol2-2)&&(button==1))
			{
				buttonclick(310,ycol2-17,330,ycol2-2);delay(50);
				lc=0;
			}
			if((x>xcol2-15)&&(y>ycol1+2)&&(x<xcol2-3)&&(y<ycol1+15)&&(button==1))
			{
				buttonclick(xcol2-15,ycol1+2,xcol2-3,ycol1+15);delay(50);
				lc=0;
			}
			if(inkey()==13)
			{ lc=0; }
		}
		hidemouse();
		back(xcol1,ycol1,xcol2,ycol2,1);
		showmouse();
		delay(90);
	}

	else if(style==3)
	{
		int width;
		if(textwidth(text)>=textwidth(title))
		width=textwidth(text)+20+45;
		if(textwidth(title)>textwidth(text))
		width=textwidth(title)+20+45;
		height=60;
		xcol1=320-(width/2),xcol2=320+(width/2);
		ycol1=240-(height/2),ycol2=240+(height/2);

		back(xcol1,ycol1,xcol2,ycol2,0);
		openwindow(xcol1,ycol1,xcol2,ycol2,title);
		setcolor(0);
		buttonon(310,ycol2-17,330,ycol2-2,"OK",3);
		setfillstyle(SOLID_FILL,RED);
		fillellipse(xcol1+15,ycol1+30,10,10);
		setcolor(15);
		settextstyle(SANS_SERIF_FONT,HORIZ_DIR,1);
		outtextxy(xcol1+15,ycol1+18,"!");
		settextstyle(SMALL_FONT,HORIZ_DIR,4);
		setlinestyle(SOLID_LINE,5,1);
		setcolor(0);
		outtextxy(xcol1+10+20,ycol1+25,text);
		showmouse();
		int lc=1;
		while(lc==1)
		{
			getmouse(button,x,y);
			if((x>310)&&(x<330)&&(y>ycol2-17)&&(y<ycol2-2)&&(button==1))
			{
				buttonclick(310,ycol2-17,330,ycol2-2);delay(50);
				lc=0;
			}
			if((x>xcol2-15)&&(y>ycol1+2)&&(x<xcol2-3)&&(y<ycol1+15)&&(button==1))
			{
				buttonclick(xcol2-15,ycol1+2,xcol2-3,ycol1+15);delay(50);
				lc=0;
			}
			if(inkey()==13)
			{ lc=0; }
		}
		hidemouse();
		back(xcol1,ycol1,xcol2,ycol2,1);
		showmouse();
		delay(90);
	}

	else if(style==4)
	{
		int width;
		if(textwidth(text)>=textwidth(title))
		width=textwidth(text)+20+45;
		if(textwidth(title)>textwidth(text))
		width=textwidth(title)+20+45;
		height=60;
		xcol1=320-(width/2),xcol2=320+(width/2);
		ycol1=240-(height/2),ycol2=240+(height/2);

		back(xcol1,ycol1,xcol2,ycol2,0);
		openwindow(xcol1,ycol1,xcol2,ycol2,title);
		setcolor(0);
		buttonon(310,ycol2-17,330,ycol2-2,"OK",3);
		setfillstyle(SOLID_FILL,RED);
		fillellipse(xcol1+15,ycol1+30,10,10);
		setcolor(15);
		settextstyle(DEFAULT_FONT,HORIZ_DIR,2);
		outtextxy(xcol1+8,ycol1+23,"i");
		settextstyle(SMALL_FONT,HORIZ_DIR,4);
		setlinestyle(SOLID_LINE,5,1);
		setcolor(0);
		outtextxy(xcol1+10+20,ycol1+25,text);
		showmouse();
		int lc=1;
		while(lc==1)
		{
			getmouse(button,x,y);
			if((x>310)&&(x<330)&&(y>ycol2-17)&&(y<ycol2-2)&&(button==1))
			{
				buttonclick(310,ycol2-17,330,ycol2-2);delay(50);
				lc=0;
			}
			if((x>xcol2-15)&&(y>ycol1+2)&&(x<xcol2-3)&&(y<ycol1+15)&&(button==1))
			{
				buttonclick(xcol2-15,ycol1+2,xcol2-3,ycol1+15);delay(50);
				lc=0;
			}
			if(inkey()==13)
			{ lc=0; }
		}
		hidemouse();
		back(xcol1,ycol1,xcol2,ycol2,1);
		showmouse();
		delay(90);
	}

	else
	MsgBox("Invalid property value for calling MsgBox style. Please enter 1 to 4.","Wrong Parameter",CRITICAL);
}

char* textfield(int x1,int y1,int length)
{
	char str[40];
	setfillstyle(1,15);
	bar(x1,y1,(x1+(8*length)),y1+15);
	buttonclick(x1,y1,(x1+(8*length)),y1+15);
	moveto(x1+2,y1);
	settextstyle(SMALL_FONT,HORIZ_DIR,4);
	isigraph(str,length);
	return (str);
}

char* inputbox(char *text,char *title,int length)
{
	hidemouse();
	settextstyle(2,0,4);
	char str[80];
	int height,xcol1,ycol1,xcol2,ycol2,len,width;
	len=length*8;
	width=strlen(text)*8;
	if(len<width)
	{
		height=60;
		xcol1=320-(width/2),xcol2=320+(width/2);
		ycol1=240-(height/2),ycol2=240+(height/2);
	}
	if(len>width)
	{
		height=60;
		xcol1=320-(len/2),xcol2=320+(len/2);
		ycol1=240-(height/2),ycol2=240+(height/2);
	}
	back(xcol1,ycol1,xcol2,ycol2+15,0);
	openwindow2(xcol1,ycol1,xcol2,ycol2+15,title);
	setcolor(0);
	buttonon(310,ycol2-5,330,ycol2+10,"OK",3);
	setcolor(0);
	outtextxy(xcol1+10,ycol1+15,text);
	setfillstyle(1,15);
	bar(xcol1+5,ycol1+30,xcol2-6,ycol1+45);
	buttonclick(xcol1+5,ycol1+30,xcol2-6,ycol1+45);
	moveto(xcol1+8,ycol1+30);
	isigraph(str,length);
	showmouse();
	showmouse();
	int lc=1;
	while(lc==1)
	{
		getmouse(button,x,y);
		if((x>310)&&(x<330)&&(y>ycol2-5)&&(y<ycol2+10)&&(button==1))
		{
			buttonclick(310,ycol2-7,330,ycol2+10);delay(50);
			lc=0;
		}
		if((x>xcol2-15)&&(y>ycol1+2)&&(x<xcol2-3)&&(y<ycol1+15)&&(button==1))
		{
			buttonclick(xcol2-15,ycol1+2,xcol2-3,ycol1+15);delay(50);
			lc=0;
		}
		if(inkey()==13)
		{ lc=0; }
	}
	hidemouse();
	back(xcol1,ycol1,xcol2,ycol2+15,1);
	showmouse();
	delay(90);
	return (str);
}

void openwindow2(int x1,int y1,int x2,int y2,char text[],int fillst,int titlecolor,int darkshade,int lightshade,int normalshade)
{
	hidemouse();
	setfillstyle(fillst,normalshade);
	bar(x1,y1,x2,y2);
	setfillstyle(1,titlecolor);
	bar(x1+1,y1+1,x2-1,y1+15);
	setfillstyle(1,normalshade);
	bar(x2-13,y1+3,x2-3,y1+12);
	settextstyle(2,HORIZ_DIR,4);
	setcolor(15);
	outtextxy(x1+2,y1+2,text);
	setcolor(lightshade);
	line(x1,y1,x2,y1);
	line(x1,y1,x1,y2);
	setcolor(darkshade);
	line(x2,y1,x2,y2);
	line(x2,y2,x1,y2);
	buttonon(x2-15,y1+2,x2-3,y1+15,"X",3);
	showmouse();
}

void openwindow(int x1,int y1,int x2,int y2,char text[],int fillst,int titlecolor,int darkshade,int lightshade,int normalshade)
{
	hidemouse();
	setfillstyle(fillst,normalshade);
	bar(x1,y1,x2,y2);
	setfillstyle(1,titlecolor);
	bar(x1+1,y1+1,x2-1,y1+15);
	setfillstyle(1,normalshade);
	bar(x2-13,y1+3,x2-3,y1+12);
	settextstyle(2,HORIZ_DIR,4);
	setcolor(15);
	outtextxy(x1+2,y1+2,text);
	setcolor(lightshade);
	line(x1,y1,x2,y1);
	line(x1,y1,x1,y2);
	setcolor(darkshade);
	line(x2,y1,x2,y2);
	line(x2,y2,x1,y2);
	buttonon(x2-15,y1+2,x2-3,y1+15,"X",3);
	showmouse();
}

void buttonon(int x1,int y1,int x2,int y2,char text[],int spc)
{
	hidemouse();
	setfillstyle(1,7);
	bar(x1,y1,x2,y2);
	setcolor(0);
	settextstyle(2,HORIZ_DIR,4);
	outtextxy(x1+1+spc,y1+1,text);
	buttoneffect(x1,y1,x2,y2);
	showmouse();
}

void buttoneffect(int x1,int y1,int x2,int y2)
{
	setcolor(15);
	line(x1,y1,x2,y1);
	line(x1,y1,x1,y2);
	setcolor(8);
	line(x2,y1,x2,y2);
	line(x1,y2,x2,y2);
}

void initaddons(char dir[])
{
	int gd=VGA,gm=VGAHI;
	initgraph(&gd,&gm,dir);
	initmouse();
	showmouse();
}

void buttonclick(int x1,int y1,int x2,int y2)
{
	hidemouse();
	setcolor(0);
	line(x1,y1,x2,y1);
	line(x1,y1,x1,y2);
	setcolor(15);
	line(x2,y1,x2,y2);
	line(x1-1,y2,x2,y2);
	setcolor(8);
	line(x1-1,y1-1,x2-1,y1-1);
	line(x1-1,y1-1,x1-1,y2-1);
	setcolor(7);
	line(x2-1,y1,x2-1,y2-1);
	line(x1-1,y2-1,x2-1,y2-1);
	showmouse();
}

cur(int on)
{
	int curx,oc;
	char ub[2]={'_',0};
	settextstyle(SMALL_FONT,HORIZ_DIR,4);
	setcolor(1);
	if(!(on))
	{
		oc=getcolor();
		setcolor(15);
	}
	curx=getx();
	outtext(ub);
	moveto(curx,gety());
	if(!on)
	setcolor(oc);
}

void isigraph(char *input,int s)
{
	int std=0,oc,c=0;
	char ch,out[2];
	int xval[255];
	out[1]=0;
	xval[0]=getx();
	do
	{
	cur(ON);
	ch=getch();
	cur(OFF);
	if(ch==0)
	getch();
	else
	{
		if(ch==8)
		{
			oc=getcolor();
			--std;
			if(std<0)
			std=0;
			moveto(xval[std],gety());
			setcolor(15);
			out[0]=input[std];
			outtext(out);
			moveto(xval[std],gety());
			setcolor(oc);
			c--;

		}
		else
		{
			input[std]=ch;
			out[0]=ch;
			if(c<s)
			{
			outtext(out);
			++std;
			xval[std]=getx();
			c++;
			}
		}
	}
}while((c<s&&ch!=13)||(ch!=13&&ch!=10));
input[std]=0;
}

void getpassword(char *input,char *passchar,int s)
{
	int std=0,oc,c=0;
	char ch,out[2];
	int xval[255];
	out[1]=0;
	xval[0]=getx();
	settextstyle(SMALL_FONT,HORIZ_DIR,4);
	do
	{
	cur(ON);
	ch=getch();
	cur(OFF);
	if(ch==0)
	getch();
	else
	{
		if(ch==8)
		{
			oc=getcolor();
			--std;
			if(std<0)
			std=0;
			moveto(xval[std],gety());
			setcolor(15);
			out[0]=input[std];
			outtext(passchar);
			moveto(xval[std],gety());
			setcolor(oc);
			c--;

		}
		else
		{
			input[std]=ch;
			out[0]=ch;
			if(c<s)
			{
			if(ch!=13)
			outtext(passchar);
			++std;
			xval[std]=getx();
			c++;
			}
		}
	}
}while((c<s&&ch!=13)||(ch!=13&&ch!=10));
input[std]=0;
}

void getstr(int s,char *input)
{
	int std=0,oc,c=0;
	char ch,out[2];
	int xval[255];
	out[1]=0;
	xval[0]=getx();
	do
	{
	cur(ON);
	ch=getch();
	cur(OFF);
	if(ch==0)
	getch();
	else
	{
		if(ch==8)
		{
			oc=getcolor();
			--std;
			if(std<0)
			std=0;
			moveto(xval[std],gety());
			setcolor(15);
			out[0]=input[std];
			outtext(out);
			moveto(xval[std],gety());
			setcolor(oc);
			c--;
		}
		else
		{
			input[std]=ch;
			out[0]=ch;
			outtext(out);
			++std;
			xval[std]=getx();
		}
	}
}while(c<s&&ch!=13&&ch!=10);
input[std]=0;
}

void checkbox(int x1,int y1,int status)
{
	setfillstyle(1,15);
	bar(x1,y1,x1+8,y1+10);
	buttonclick(x1,y1,x1+8,y1+10);
	if(status==1)
	{
		setfillstyle(1,0);
		bar(x1+2,y1+2,x1+6,y1+8);
	}
	if(status==0)
	{
		setfillstyle(1,15);
		bar(x1+2,y1+2,x1+6,y1+8);
	}
}

void progressbar(int x1,int y1,int status,int display)
{
	if(display==1)        //make
	{
		setfillstyle(1,7);
		bar(x1,y1,x1+50,y1+10);
		buttonclick(x1,y1,x1+54,y1+10);
		setfillstyle(1,2);
		bar(x1+2,y1+2,(x1+(status/2)),y1+8);
	}
	else if(display==0)         //operate
	{
		setfillstyle(1,2);
		bar(x1+2,y1+2,(x1+(status/2)),y1+8);
	}
}

void menu(int xcol,int ycol,char *list[],int height,int width)
{
	int h=(height*15)+10;
	int w=width*8;
	setfillstyle(1,7);
	bar(xcol,ycol,xcol+w,ycol+h);
	buttoneffect(xcol,ycol,xcol+w,ycol+h);
	settextstyle(2,HORIZ_DIR,4);
	setcolor(0);
	for(int a=0;a<height;a++)
	{
		outtextxy(xcol+3,(ycol+2+(a*15)),list[a]);
	}
}


void marquee(char text[],int x1,int y1,int x2,int dir)
{
	int c=getcolor(),d,e=0;
	float *backgr;
	backgr=new float[100];
	for(int col=x2;col>=x1;col--)
	{
		if(col>x2+200)
		{
			e=x2-col;
		}
		else
		{
			e=200;
		}
		getimage(col-1,y1,(col-1)+textwidth(text),y1+textheight(text)+10,backgr);
		outtextxy(col,y1,text);
		delay(20);
		putimage(col-1,y1,backgr,COPY_PUT);
	}
	delete backgr;
}

// Now I introduce Mouse Functions

void initmouse()
{
	i.x.ax=0;
	int86(0x33,&i,&o);
}

void showmouse()
{
       i.x.ax=1;
       int86(0x33,&i,&o);
}

void hidemouse()
{
       i.x.ax=2;
       int86(0x33,&i,&o);
}

void getmouse(int& button,int& x,int& y)
{
       i.x.ax=3;
       int86(0x33,&i,&o);
       button= o.x.bx;
       x=o.x.cx;
       y=o.x.dx;
}
void setmouse(int x,int y)
{
	i.x.ax=4;
	i.x.cx=x;
	i.x.dx=y;
	int86(0x33,&i,&o);
}

void getmousepos(int *button,int *x,int *y)
{
       i.x.ax=3;
       int86(0x33,&i,&o);
       *button= o.x.bx;
       *x=o.x.cx;
       *y=o.x.dx;
}

void restrictmouse(int x1,int y1,int x2,int y2)
{
      i.x.ax=7;
      i.x.cx=x1;
      i.x.dx=x2;
      int86(0x33,&i,&o);
      i.x.ax=8;
      i.x.cx=y1;
      i.x.dx=y2;
      int86(0x33,&i,&o);
}

void mouseptr(int mark[50],int xstart,int ystart)
{
      i.x.ax=9;
      i.x.bx=xstart;
      i.x.cx=ystart;
      i.x.dx=(int)mark;
      segread(&s);
      s.es=s.ds;
      int86x(0x33,&i,&i,&s);
}

void getclick(int bta,int btb,int link[][5])
{
	while(loopmain!=0)
	{
		getmouse(button,x,y);
		for(int bd=bta;bd<=btb;bd++)
		{
			getmouse(button,x,y);

		}
	}
}

int getlink(int bta,int btb,int link[][5])
{
	while(loopmain!=0)
	{
		getmouse(button,x,y);
		for(int bd=bta;bd<=btb;bd++)
		{
			getmouse(button,x,y);
			if((x>link[bd][0])&&(y>link[bd][1])&&(x<link[bd][2])&&(y<link[bd][3])&&(button==link[bd][4]))
			{
				return(bd);
			}
		}
	}
	return(0);
}


void activate(int x1,int y1,int x2,int y2,int n,int link[][5],int forbtn)
{ link[n][0]=x1;
  link[n][1]=y1;
  link[n][2]=x2;
  link[n][3]=y2;
  link[n][4]=forbtn;
}

void pressbtn(int no,int link[][5])
{ hidemouse();
  buttonclick(link[no][0],link[no][1],link[no][2],link[no][3]);
  showmouse();
}

void liftbtn(int no,int link [][5])
{ hidemouse();
  buttoneffect(link[no][0],link[no][1],link[no][2],link[no][3]);
  showmouse();
}

void endgui()
{ closegraph();restorecrtmode();exit(1);
}

int activemenu(int xc1,int yc1,char *list[],int rows,int cols)
{ hidemouse();
  /*back(xc1,yc1,xc1+(rows*15)+10,yc1+(cols*8)+10,0);*/
  /*menu(xc1,yc1,test,rows,cols);*/
  int h=((rows*15)+10);
  int w=((cols*8)+10);
  setfillstyle(1,7);
  float *bck;
  float sz=imagesize(xc1,yc1,xc1+w,yc1+h);
  bck=new float[sz];
  getimage(xc1,yc1,xc1+w,yc1+h,bck);
  bar(xc1,yc1,xc1+w,yc1+h);
  buttoneffect(xc1,yc1,xc1+w,yc1+h);
  settextstyle(2,HORIZ_DIR,4);
  setcolor(0);
  for(int a=0;a<rows;a++)
  { outtextxy(xc1+3,(yc1+2+(a*15)),list[a]);
  }
  showmouse();
  getmouse(button,x,y);
  int lc=1,fnc=0,over=-1;
  delay(50);
  while(lc==1)
  { getmouse(button,x,y);
    for(int b=0;b<rows;b++)
    { if(button==1)
      { if((x>xc1+w)||(x<xc1)||(y>yc1+h)||(y<yc1))
	  { fnc=0;lc=0;
	  }
	else if((y>(yc1+(15*b)))&&(y<(yc1+(15*b)+15)))
	  { fnc=b+1;
	    lc=0;
	  }

      }
      if(button==0)
      { if((y>(yc1+(15*b)))&&(y<(yc1+(15*b)+15)))
	{ if((b!=over)||(over==-1))
	  { if(over!=-1)
	     {invertcolors(xc1+2,yc1+(15*over)+1,xc1+w-2,yc1+(15*over)+13);}
	    invertcolors(xc1+2,yc1+(15*b)+1,xc1+w-2,yc1+(15*b)+13);over=b;
	  }
	  over=b;
	}
      }
    }
  }
    hidemouse();
    putimage(xc1,yc1,bck,COPY_PUT);
    showmouse();
    delete bck;
    return(fnc);

}

void back(int x1,int y1,int x2,int y2,int mode,char *file)
{  int ch;char c2;
   if(mode==0)
   {
     float sts=4;
     ofstream outfile(file);
     for(int b=y1;b<=y2;b++)
     { for(int a=x1;a<=x2;a++)
       { ch=getpixel(a,b);
	 outfile<<(char)(ch+28);
       }
       sts+=(((a-x1)/(x2-x1))*100);
     }
     outfile.close();
   }
   else if(mode==1)
   {
     ifstream infile(file);
     for(int b=y1;b<=y2;b++)
     { for(int a=x1;a<=x2;a++)
       { infile.get(c2);ch=(int)c2;
	 putpixel(a,b,ch-28);
       }
     }
     infile.close();

   }
}

void say(char text[],char title[])
{
  hidemouse();
  settextstyle(2,0,4);
  int width=textwidth(text)+20;
  int height=60;
  int xcol1=320-(width/2),xcol2=320+(width/2);
  int ycol1=240-(height/2),ycol2=240+(height/2);
/*  float sz=imagesize(xcol1,ycol1,xcol2,ycol2);
  float *bk;
  bk=new float[sz];
  getimage(xcol1,ycol1,xcol2,ycol2,bk);*/
  back(xcol1,ycol1,xcol2,ycol2,0);
  openwindow(xcol1,ycol1,xcol2,ycol2,title);
  setcolor(0);
  buttonon(310,ycol2-17,330,ycol2-2,"OK",3);
  setcolor(0);
  outtextxy(xcol1+10,ycol1+20,text);
  showmouse();
  int lc=1;               //x2-15,y1+2,x2-3,y1+15
  while(lc==1)
  { getmouse(button,x,y);
    if((x>310)&&(x<330)&&(y>ycol2-17)&&(y<ycol2-2)&&(button==1))
    { buttonclick(310,ycol2-17,330,ycol2-2);delay(50);
      lc=0;
    }
    if((x>xcol2-15)&&(y>ycol1+2)&&(x<xcol2-3)&&(y<ycol1+15)&&(button==1))
    { buttonclick(xcol2-15,ycol1+2,xcol2-3,ycol1+15);delay(50);
      lc=0;
    }
    if(inkey()==13)
    { lc=0; }
  }
  hidemouse();
 back(xcol1,ycol1,xcol2,ycol2,1);
  showmouse();
  delay(90);
}

char* intext(int x1,int y1)   //intext
{ setcolor(0);
  settextstyle(2,0,4);
  int xcn=0;int in2=0;
  char in[2];
  char *yotext;
  in[1]='';
  while(*in!=(char)13)
  { st:
    in[0]=getch();
    if(in[0]==(char)13)
     { break;
     }
    else if
    (in[0]==(char)8)
    {in2-=6;xcn--;setfillstyle(1,15);bar(x1+in2,y1,x1+in2+textwidth("W"),y1+textheight("Wg"));goto st;}
    setfillstyle(1,15);bar(x1+in2,y1,x1+in2+textwidth(in),y1+textheight(in));
    outtextxy(x1+in2,y1,in);
    in2+=6;
    yotext[xcn]=in[0];
    xcn++;
  }
  yotext[xcn]='';
  return(yotext);
}

int confirm(char text[],char title[])
{
  hidemouse();
  settextstyle(2,0,4);
  int width=textwidth(text)+20;
  int height=60;
  int xcol1=320-(width/2),xcol2=320+(width/2);
  int ycol1=240-(height/2),ycol2=240+(height/2);
  /*float sz=imagesize(xcol1,ycol1,xcol2,ycol2);
  float *bk;
  bk=new float[sz];
  getimage(xcol1,ycol1,xcol2,ycol2,bk);*/
  back(xcol1,ycol1,xcol2,ycol2,0);
  openwindow(xcol1,ycol1,xcol2,ycol2,title);
  setcolor(0);
  buttonon(320-31,ycol2-17,320-1,ycol2-2,"OK",6);
  buttonon(320+1,ycol2-17,320+41,ycol2-2,"Cancel",3);
  sel(320+1,ycol2-17,320+41,ycol2-3,1);
  setcolor(0);
  outtextxy(xcol1+10,ycol1+20,text);
  showmouse();
  int lc=1,ans=0,opt=2,in;               //x2-15,y1+2,x2-3,y1+15
  while(lc==1)
  { getmouse(button,x,y);
    in=inkey();
    if((x>320-31)&&(x<320-1)&&(y>ycol2-17)&&(y<ycol2-2)&&(button==1))
    { buttonclick(320-31,ycol2-17,320-1,ycol2-2);delay(50);ans=1;
      lc=0;
    }
    if((x>xcol2-15)&&(y>ycol1+2)&&(x<xcol2-3)&&(y<ycol1+15)&&(button==1))
    { buttonclick(xcol2-15,ycol1+2,xcol2-3,ycol1+15);delay(50);
      lc=0;
    }
     if((x>320+1)&&(x<320+41)&&(y>ycol2-17)&&(y<ycol2-2)&&(button==1))
     { buttonclick(320+1,ycol2-17,320+41,ycol2-2);delay(50);ans=0;
       lc=0;
     }

     if(in==13)
     { if(opt==1) {ans=1;}
       else if(opt==2) {ans=0;}
       lc=0;
     }
     if(in==75)
     { opt=1;
       sel(320-31,ycol2-17,320-1,ycol2-3,1);
       sel(320+1,ycol2-17,320+41,ycol2-3,0);
     }
     if(in==77)
     { opt=2;
       sel(320-31,ycol2-17,320-1,ycol2-3,0);
       sel(320+1,ycol2-17,320+41,ycol2-3,1);
     }

  }
  hidemouse();
  back(xcol1,ycol1,xcol2,ycol2,1);
  /*putimage(xcol1,ycol1,bk,COPY_PUT);
  delete bk;*/
  showmouse();
  delay(90);
  return(ans);
}

void cmdbtn(int x1,int y1,int x2,int y2,char text[],int no,int link[][5],int forbtn)
{ buttonon(x1,y1,x2,y2,text,3);
  activate(x1,y1,x2,y2,no,link,forbtn);
}
void iconbtn(int x1,int y1,int x2,int y2,char text[],int no,int link[][5],int forbtn)
{ buttonon(x1,y1,x2,y2,"",3);
  activate(x1,y1,x2,y2,no,link,forbtn);
  image(x1+3,y1+3,x2-3,y2-3,text);
}

void image(int x1,int y1,int x2,int y2,char filename[])
{
     char c2;
     int width,height,ch;
     ifstream infile(filename);
     if(infile)
     {	infile>>width>>height;
	setviewport(x1,y1,x2,y2,1);
	hidemouse();
	for(int a=0;a<=width;a++)
	{ for(int b=0;b<=height;b++)
	  { infile.get(c2);ch=(int)c2;
	    putpixel(a,b,ch-28);
	  }
	}
	setviewport(0,0,639,479,1);
	showmouse();
     }
     infile.close();
}


class windows
{ private:
   int xcol1,ycol1,xcol2,ycol2;
   char *titleofwindow;
  public:
   void newwindow(int x1,int y1,int x2,int y2,char tit[])
    { xcol1=x1;ycol1=y1;xcol2=x2;ycol2=y2;
      titleofwindow=tit;
      hidemouse();
      back(xcol1,ycol1,xcol2,ycol2,0,tit);
      openwindow(xcol1,ycol1,xcol2,ycol2,tit);
      showmouse();
    }
   void setcolors(int titlecol,int darkshade,int lightshade,int normalfill,int fillstyle)
    { openwindow(xcol1,ycol1,xcol2,ycol2,titleofwindow,fillstyle,titlecol,darkshade,lightshade,normalfill);
    }
   void closewindow()
    { hidemouse();
      back(xcol1,ycol1,xcol2,ycol2,1,titleofwindow);
      showmouse();
      remove(titleofwindow);
    }
};

class textbox
{ private:
    char *textfill;
    int x1,y1,len;
    int *bck;
  public:
  void make(int xc1,int yc1,int leng)
  { bck=new int[imagesize(xc1,yc1,xc1+(8*leng),yc1+15)];
    getimage(xc1,yc1,xc1+(8*leng),yc1+15,bck);
    x1=xc1; y1=yc1; len=leng;
    textfield(xc1,yc1,leng);
  }
  void text(char tex[])
  { setfillstyle(1,15);
    bar(x1+2,y1+2,x1+textwidth(tex),y1+13);
    settextstyle(2,HORIZ_DIR,4);
    setcolor(0);
    outtextxy(x1+2,y1+2,tex);
    textfill=strcpy(textfill,tex);
  }
  char *qtext()
  { return(textfill);}
  void clear()
  { putimage(x1,y1,bck,COPY_PUT); }
};

class check
{ private:
   int x1,y1;
  public:
   int stat;
   void make(int xc1,int yc1)
   { checkbox(xc1,yc1,0);
     x1=xc1; y1=yc1; stat=0;
   }
   void on()
   { checkbox(x1,y1,1); stat=1; }
   void off()
   { checkbox(x1,y1,0); stat=0; }

};

void pointer(int pt)
{
 int arrow[32]={ 0x9fff,0x8fff,0x87ff,0x83ff,0x81ff,0x80ff,0x807f,0x803f,0x801f,0x800f,0x80ff,
	       0x887f,0x987f,0xfc3f,0xfc3f,0xfe3f,0x0000,0x2000,0x3000,0x3800,0x3c00,0x3e00,
	       0x3f00,0x3f80,0x3fc0,0x3e00,0x3600,0x2300,0x0300,0x0180,0x0180,0x0000
	    };
int ibeam[32]={ 0xe187,0xe007,0xfc3f,0xfc3f,0xfc3f,0xfc3f,0xfc3f,0xfc3f,0xfc3f,0xfc3f,0xfc3f,
	      0xfc3f,0xfc3f,0xfc3f,0xe007,0xe187,0x0000,0x0e70,0x0180,0x0180,0x0180,0x0180,
	      0x0180,0x0180,0x0180,0x0180,0x0180,0x0180,0x0180,0x0180,0x0e70,0x0000
	    };
int cursor[32]={ 0xff7f,0xff7f,0xff7f,0xff7f,0xff7f,0xff7f,0xff7f,0xff7f,
		   0x0080,0xff7f,0xff7f,0xff7f,0xff7f,0xff7f,0xff7f,0xff7f,
		   0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
		   0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000
		    };
int wait[32]={ 0x8001,0xc003,0xc003,0xc003,0xc003,0xe007,0xf00f,0xf81f,0xf81f,0xf00f,0xe007,
	       0xc003,0xc003,0xc003,0xc003,0x8001,0x7ffe,0x2004,0x2004,0x2004,0x2664,0x13c8,
	       0x0990,0x0420,0x0420,0x0990,0x13c8,0x27e4,0x2ff4,0x2ff4,0x2004,0x7ffe
	      };
int icon[32]={ 0xffff,0xffff,0xc003,0xc003,0xc003,0xc003,0xc003,0xc003,0xc003,0xc003,0xc003,
	       0xc003,0xc003,0xc003,0xffff,0xffff,0x0000,0x0000,0x3ffc,0x3ffc,0x300c,0x300c,
	       0x33cc,0x33cc,0x33cc,0x33cc,0x300c,0x300c,0x3ffc,0x3ffc,0x0000,0x0000
	      };



hidemouse();
switch(pt)
{ case 1: mouseptr(arrow,1,1);break;
  case 2: mouseptr(ibeam,1,1);break;
  case 3: mouseptr(wait,1,5);break;
  case 4: mouseptr(icon,8,8);break;
  default:break;
}
showmouse();
}

int inkey()
{ char k;
  if(kbhit())
  { k=getch();
    if(k==0)
    { k=getch();
      return((int)k);
    }
    else{ return((int)k);}
  }
  return(0);
}

void sel(int x1,int y1,int x2,int y2,int md)
{ hidemouse();
  if(md==1)  // select
  { setcolor(0);
    rectangle(x1-1,y1-1,x2+1,y2+2);
  }
  else
  { setcolor(7);
    rectangle(x1-1,y1-1,x2+1,y2+2);
  }
  showmouse();
}

void select(int x1,int y1,int x2,int y2,int md)
{
	setlinestyle(DOTTED_LINE,0,1);
	if(md==1)  // Select
	{
		setcolor(0);
		rectangle(x1-1,y1-1,x2+1,y2+2);
	}
	else      // Deselect
	{
		setcolor(7);
		rectangle(x1-1,y1-1,x2+1,y2+2);
	}
	setlinestyle(SOLID_LINE,0,1);
}

void select_with_color(int x1,int y1,int x2,int y2,int color)
{
	setlinestyle(DOTTED_LINE,0,1);
	setcolor(color);
	rectangle(x1-1,y1-1,x2,y2);
	setlinestyle(SOLID_LINE,0,1);
}

void deselect_with_color(int x1,int y1,int x2,int y2,int color)
{
	setlinestyle(DOTTED_LINE,0,1);
	setcolor(color);
	rectangle(x1-1,y1-1,x2,y2);
	setlinestyle(SOLID_LINE,0,1);
}

void invertcolors(int x1,int y1,int x2,int y2)
{  int cl;
   hidemouse();
   for(int a=x1;a<=x2;a++)
   { for(int b=y1;b<=y2;b++)
     { cl=getpixel(a,b);
       putpixel(a,b,15-cl);
     }
   }
   showmouse();
}


/*******************************************************/
/*                                                     */
/*  VGASetAllPalette sets 256 colors and border color  */
/*						       */
/*******************************************************/

void VGASetAllPalette (VGAPaletteType P)  //This function gets a structure f all 256 colors.
{
    struct REGPACK Regs;
    Regs.r_ax = 0x1012;
    Regs.r_bx = 0;
    Regs.r_cx = 256;
    Regs.r_es = FP_SEG (P);
    Regs.r_dx = FP_OFF (P);

    intr (0x10, &Regs);
} /* VGASetAllPalette*/


/*****************************************************/
/*                                                   */
/*  HSI2Rgb converts hue H, Saturation S and         */
/*          Intensity I to Red-Green-Blue components */
/*						     */
/*****************************************************/

void Hsi2Rgb (double H, double S, double I, struct ColorValue * C)
{
    double T  = 2 * M_PI * H;                   /* direction on the circle */
    double Rv = 1 + S * sin(T - 2 * M_PI / 3);  /* R                      */
    double Gv = 1 + S * sin(T);                 /* G  > components (0..2)  */
    double Bv = 1 + S * sin(T + 2 * M_PI / 3);  /* B /                     */

    T = 63.999 * I / 2;				/* max color intensity = 63*/

    C->Rvalue = (int)(Rv * T);
    C->Gvalue = (int)(Gv * T);
    C->Bvalue = (int)(Bv * T);

} /*{ Hsi2Rgb }*/

int AddColor (int *colorno, struct ColorValue *C, VGAPaletteType P)
{
    int i, curcolor;

    for (curcolor = 0, i = 1; i < *colorno; i++)  /* scan those already existing */
    {
	if (P[i].Rvalue == C->Rvalue     /* if we 		*/
	&&  P[i].Gvalue == C->Gvalue     /* already have		*/
	&&  P[i].Bvalue == C->Bvalue)    /* this color		*/
	{
	    curcolor = i;		/* then use this color  */
	    break;
	}
    }

    if (!curcolor)			/* Otherwise!    */
    {
	if (*colorno < 255)		/* if not overflow */
	{
	    curcolor = (*colorno)++;    /* add then a new color */
	    P[curcolor] = *C;		/* to the palette */
	    VGASetAllPalette(P);	/* and reset the palette */
	}
    }

    return curcolor;
}



/***********************************************/
/*                                             */
/*   Hue demonstrates a hue circle         */
/*           of maximal saturations            */
/*                                             */
/***********************************************/


int Hue(int left,int top,int right,int bottom,int xcent,int ycent)
{
    const int xcenter =xcent, ycenter = ycent;//ycenter is top. xcenter is middle from top.
    char buf[281];        	/* buffer for sprintf */
    double H, S;
    VGAPaletteType P;		/* contains all 256 colors definition */
    struct ColorValue C;
    int     x,  y, Z;
    double rx, ry;
    int colorno = 1, curcolor;

    getaspectratio (&xasp, &yasp);
/* make almost all colors blackest black */
    for (Z = 0; Z < 255; Z++)
    {
	P[Z].Rvalue = 0;
	P[Z].Gvalue = 0;
	P[Z].Bvalue = 0;
    }
/* make color 255 whitest white */
    P[253].Rvalue = 63;
    P[253].Gvalue = 63;
    P[253].Bvalue = 63;

    VGASetAllPalette(P);  /* A preparatory measure */

    for (y = top; y < bottom  ; y++)  /*scan a square round the circle*/
    {
    for (x = left; x < right; x++)              /*scan the square*/ //0 is left and 800 is right.
    {
	rx = (double)(x - xcenter) / yasp;  /* weighted x-distance */
	ry = (double)(y - ycenter) / xasp;  /* weighted y-distance */

	S =  sqrt (rx * rx + ry * ry);  /* distance to center */ //1000 is square and 10000 is round.

	if (S < 1.)                         /* not too far? */
	{
	    if (S > .0000001)               /* not too near? */
		H = .5 + atan2 (ry, rx) / M_PI / 2; /* hue circular value */
	    else
		H = 0.;		    /* atan2 does not work in microcosm */

	    H = (int)(H*290.5)/ 290.5; /* discretize it to avoid color overflow */

	    Hsi2Rgb (H, 1., 1., &C); /* convert to RGB */

	    curcolor = AddColor (&colorno, &C, P);
	    if (curcolor)
		putpixel (x, y, curcolor);
	    else
	    {
		setcolor (1);
		outtextxy (1, ycenter, "Out of colors, press a key!");
		while (!kbhit());
		break;
	    }
	}
    }
    }

    VGASetAllPalette(P);
}

class ComboMenu
{
	private:

	int l,t,r,b,btop,bbottom,length;
	int row;

	public:

	void Show(int left,int top,char*list[],int rows)
	{

		int h=((rows*15)+10);
		int s=1,size;

		settextstyle(2,0,4);
		for ( int i = 0 ; i < rows ; i++ )
		{
			if ( strlen ( list[i] ) > s )
			{
				s = strlen ( list[i] ) ;
				s=s;
			}
		}
		s=s*8+20;
		size=s;
		int w=size;
		length=w;

		back(left,top,left+w,top+h,0);

		setfillstyle(1,15);
		bar(left,top,left+w,top+h);
		//buttoneffect(left,top,left+w,top+h);
		settextstyle(2,HORIZ_DIR,4);
		setcolor(0);
		for(int a=0;a<rows;a++)
			outtextxy(left+3,(top+2+(a*15)),list[a]);

		l=left,t=top,r=left+w,b=top+h;
		btop=t;bbottom=btop+15;
		row=rows;
		invertcolors(l+2,t+2,r-3,t+15);
	}

	int Keypress(char *list[])
	{
		static int counter=0;
		static int scrollup=0;
		static int scrolldown=0;
		int scrolltime=row;

		int h=((row*15)+10);
		int s=1,size;

		settextstyle(2,0,4);
		for ( int i = 0 ; i < row ; i++ )
		{
			if ( strlen ( list[i] ) > s )
			{
				s = strlen ( list[i] ) ;
				s=s;
			}
		}
		s=s*8+20;
		size=s;
		int w=size;
		length=w;

		while(1)
		{
			int in,ret;
			in=inkey();

			if(in==72)
			{
				if(scrollup>0)
				{
					scrollup--;
					invertcolors(l+2,btop+2,r-3,bbottom);
					btop=btop-15;
					bbottom=bbottom-15;
					invertcolors(l+2,btop+2,r-3,bbottom);
					scrolldown=scrollup;
					counter=scrollup;
					return scrollup+1;
				}
			}

			if(in==80)
			{
				if(scrolldown<scrolltime-1)
				{
					scrolldown++;
					counter++;
					invertcolors(l+2,btop+2,r-3,bbottom);
					btop=btop+15;
					bbottom=bbottom+15;
					invertcolors(l+2,btop+2,r-3,bbottom);
					scrollup=counter;
					ret=scrolldown+1;
					//counter=scrolldown;
					return ret;
				}
			}
			if(in==13)
			{
				counter=0;
				scrolldown=0;
				scrollup=0;
				back(l,t,l+w,t+h,1);
				return -1;
				break;
			}
		}
		counter=0;
		scrolldown=0;
	}
};

GCPPMAIN.H

			    /*    GRAPHICAL C++   */
		    /* DEVELOPED BY DEBASIS BHATTACHARJEE */

#include<gcppfunc.h>

int bkcolor=7;
int butcolor=7;
int l=120,t=100,r=500,b=400;
int hide=0;

class Frame
{
	private:

	int capcolor,labcolor;
	int capyes,capcolyes,labcolyes;
	int left,top;
	char labcap[800];

	public:

		Show(int l,int t,int r,int b,char cap[40])
		{
			setcolor(15);
			rectangle(l+1,t+1,r+1,b+1);
			setcolor(8);
			rectangle(l,t,r,b);
			settextstyle(SMALL_FONT,HORIZ_DIR,4);
			int size=strlen(cap)*8;
			setfillstyle(SOLID_FILL,7);
			bar(l+10,t-5,l+size+15,t+5);
			setcolor(0);
			outtextxy(l+13,t-5,cap);
		}

		Show(int l,int t,int r,int b)
		{
			int size;
			setcolor(15);
			rectangle(l+1,t+1,r+1,b+1);
			setcolor(8);
			rectangle(l,t,r,b);
			if(capyes==-1)
			{
			settextstyle(SMALL_FONT,HORIZ_DIR,4);
			size=textwidth(labcap);
			if(labcolyes==-1)
			setfillstyle(SOLID_FILL,labcolor);
			else
			setfillstyle(SOLID_FILL,7);
			bar(l+10,t-5,l+size+15,t+5);
			if(capcolyes==-1)
			setcolor(capcolor);
			else
			setcolor(0);
			outtextxy(l+13,t-5,labcap);
			}
			else
			{
			settextstyle(SMALL_FONT,HORIZ_DIR,4);
			size=textwidth("GCPPFrame");
			if(labcolyes==-1)
			setfillstyle(SOLID_FILL,labcolor);
			else
			setfillstyle(SOLID_FILL,7);
			bar(l+10,t-5,l+size+15,t+5);
			if(capcolyes==-1)
			setcolor(capcolor);
			else
			setcolor(0);
			outtextxy(l+13,t-5,"GCPPFrame");
			}
		}

		void Caption(char cap[800])
		{
			strcpy(labcap,cap);
			capyes=-1;
		}

		void Fontcolor(int color)
		{
			capcolor=color;
			capcolyes=-1;
		}

		void Backcolor(int bkcolor)
		{
			labcolor=bkcolor;
			labcolyes=-1;
		}
};

class Label
{
	private:

	int backcolor,backcolyes;
	int fontcolor,fontcolyes;
	int capyes;
	int left,top;
	char *labcap;
	int len;

	public:
	void Show(int l,int t,char *cap)
	{
		settextstyle(SMALL_FONT,HORIZ_DIR,4);
		int length=textwidth(cap);
		length=length+10;
		len=length;
		setfillstyle(SOLID_FILL,7);
		bar(l,t,l+length,t+15);
		setcolor(0);
		outtextxy(l+5,t+2,cap);
		left=l;
		top=t;
	}

	void Show(int l,int t)
	{
		int length;
		settextstyle(SMALL_FONT,HORIZ_DIR,4);
		if(capyes==1)
		{
		length=textwidth(labcap);
		length=length+10;
		len=length;
		if(backcolyes==-1)
		setfillstyle(SOLID_FILL,backcolor);
		else
		setfillstyle(SOLID_FILL,7);
		bar(l,t,l+length,t+15);
		if(fontcolyes==-1)
		setcolor(fontcolor);
		else
		setcolor(0);
		outtextxy(l+5,t+2,labcap);
		}
		else
		{
		length=textwidth("GCPPLabel");
		length=length+10;
		len=length;
		if(backcolyes==-1)
		setfillstyle(SOLID_FILL,backcolor);
		else
		setfillstyle(SOLID_FILL,7);
		bar(l,t,l+length,t+15);
		if(fontcolyes==-1)
		setcolor(fontcolor);
		else
		setcolor(0);
		settextstyle(SMALL_FONT,HORIZ_DIR,4);
		outtextxy(l+5,t+2,"GCPPLabel");
		}

		left=l;
		top=t;
	}

	void Caption(char cap[40])
	{
		strcpy(labcap,cap);
		capyes=1;
	}

	void Backcolor(int bkcolor)
	{
		backcolor=bkcolor;
		backcolyes=-1;
	}

	void Fontcolor(int color)
	{
		fontcolor=color;
		fontcolyes=-1;
	}

	Getrightpos()
	{
		return len;
	}
};

class CheckBox
{
	private:

	int capyes;
	int left,top;
	char *labcap;

	public:

	void Show(int l,int t)
	{
		setfillstyle(1,15);
		bar(l,t,l+11,t+10);
		buttonclick(l,t,l+11,t+10);
		setcolor(8);
		rectangle(l-1,t-1,l+10,t+9);
		left=l,top=t;
	}

	int Check()
	{
		int check=0;
		int val=3;
		showmouse();
		while(1)
		{
			getmouse(button,x,y);
			if((x>=left)&&(x<left+12)&&(y>=top)&&(y<top+12)&&(button==1))
			val=1;
			if((x>=left)&&(x<left+12)&&(y>=top)&&(y<top+12)&&(button==2))
			val=0;

			if(val==1)
			{
				hidemouse();
				setcolor(0);
				setlinestyle(SOLID_LINE,0,3);
				line(left+2,top+4,left+4,top+6);
				line(left+5,top+6,left+8,top+3);
				setlinestyle(SOLID_LINE,0,1);
				check=1;
				break;
			}
			if(val==0)
			{
				hidemouse();
				setcolor(15);
				setlinestyle(SOLID_LINE,0,3);
				line(left+2,top+4,left+4,top+6);
				line(left+5,top+6,left+8,top+3);
				setlinestyle(SOLID_LINE,0,1);
				check=0;
				break;
			}
		}
		showmouse();
		return check;
	}

	int Keypress()
	{
		static int check=0;
		int val=3;
		int in,checktake=0,counttake=0;
		static int count=0;

		while(1)
		{
			in=getch();

			if(in==32)
			{
				switch(count)
				{
					case 0:
					val=1;
					count=1;
					break;

					case 1:
					val=0;
					count=0;
					break;
				}
			}

			if(in==13||in==9)
			{
				checktake=check;
				counttake=count;
				check=0;
				count=0;
				return checktake+2;
				break;
			}

			if(val==1)
			{
				setcolor(0);
				setlinestyle(SOLID_LINE,0,3);
				line(left+2,top+4,left+4,top+6);
				line(left+5,top+6,left+8,top+3);
				setlinestyle(SOLID_LINE,0,1);
				check=1;
				break;
			}
			if(val==0)
			{
				setcolor(15);
				setlinestyle(SOLID_LINE,0,3);
				line(left+2,top+4,left+4,top+6);
				line(left+5,top+6,left+8,top+3);
				setlinestyle(SOLID_LINE,0,1);
				check=0;
				break;
			}
		}
	}

	void Checked()
	{
		setcolor(0);
		setlinestyle(SOLID_LINE,0,3);
		line(left+2,top+4,left+4,top+6);
		line(left+5,top+6,left+8,top+3);
		setlinestyle(SOLID_LINE,0,1);
	}

	void UnChecked()
	{
		setcolor(15);
		setlinestyle(SOLID_LINE,0,3);
		line(left+2,top+4,left+4,top+6);
		line(left+5,top+6,left+8,top+3);
		setlinestyle(SOLID_LINE,0,1);
	}

	void Selection(int color)
	{
		select_with_color(left-2,top-2,left+11+2,top+10+2,color);
	}

	void Deselection(int color)
	{
		deselect_with_color(left-2,top-2,left+11+2,top+10+2,color);
	}
};


class GeneralCombo
{
	private:

		int textyes;
		char* combo_text;

	public:

		void Text(char* comtext)
		{
			combo_text=comtext;
			textyes=1;
		}

		int Show(char *list[],int l,int t,int row)
		{
			int s=1,st=1;static int ii,count;
			int size=0,buttonleft=0;
			int ret;
			char *greater;
			char *select;

			if(textyes==1)
			select=combo_text;
			else
			select=list[0];

			for ( int i = 0 ; i < row ; i++ )
			{
				if ( strlen ( list[i] ) > s )
				{
					s = strlen ( list[i] ) ;
					s=s;
				}
			}

			s=s*8;
			size=s+30;
			buttonleft=size;
			size=size/8;

			if(count!=1)
			textarea(select,l,t,size);

			int ml=l,mt=t,mr=l+buttonleft-6,mb=t+14;
			int ll=mr-12,lt=mt+6,lr=mr-7,lb=mt+6; //for lines in mybutton to create arrow.

			mybutton(mr-16,mt+1,mr-2,mb-1);
			for(int j=0;j<=2;j++)
			{
				setcolor(0);
				line(ll,lt,lr,lb);
				ll=ll+1,lr=lr-1;
				lt=lt+1,lb=lb+1;
			}

			showmouse();

			while(!kbhit())
			{
				getmouse(button,x,y); //Get Mouse
				if((x>ml)&&(x<mr)&&(y>mt)&&(y<mb)&&(button==1))
				{
					delay(200);
					ret=mymenu(ml-2,mt+18,list,6,size-1);
					for(ii=1;ii<=row;ii++)
					{
						if(ii==ret)
						{
							select=list[ii-1];
							count=1;
						}
					}

					textarea(select,l,t,size);
					return ret;
				}
			}
		}
};

class TextBox
{
private:

	int left,top,r,character,set_focus_used_yes;
	int length;
	char text[80];

public:

	void Show(int x1,int y1,int len)
	{
		char str[40];
		setfillstyle(1,15);
		int right;
		right=x1+(8*len);
		bar(x1,y1,right,y1+15);
		buttonclick(x1,y1,right,y1+15);
		left=x1,top=y1;
		character=len;
		r=right;
		length=right;
	}

	char* GetInput()
	{
		char str[80];
		moveto(left+2,top);
		settextstyle(SMALL_FONT,HORIZ_DIR,4);
		isigraph(str,character);
		strcpy(text,str);
		return (str);
	}

	void Text(char *text)
	{
		int width;
		width=textwidth(text);
		width=width+left;
		if(width>r)
		{
		setfillstyle(1,15);
		bar(left,top,width+4,top+15);
		buttonclick(left,top,width+4,top+15);
		moveto(left+2,top);
		settextstyle(SMALL_FONT,HORIZ_DIR,4);
		setcolor(1);
		outtext(text);
		r=width+4;
		}
		else
		{
		moveto(left+2,top);
		settextstyle(SMALL_FONT,HORIZ_DIR,4);
		setcolor(1);
		outtext(text);
		}
	}

	char* Text(void)
	{
		return text;
	}

	char* Password(char *pass)
	{
		char str[80];
		moveto(left+2,top);
		settextstyle(SMALL_FONT,HORIZ_DIR,4);
		getpassword(str,pass,character);
		return (str);
	}

	void Clear()
	{
		setfillstyle(1,15);
		bar(left,top,r,top+15);
		buttonclick(left,top,r,top+15);
	}

	Getrightpos()
	{
		return length;
	}

	void Selection(int color)
	{
		select_with_color(left-2,top-2,length+2,top+15+2,color);
	}

	void Deselection(int color)
	{
		deselect_with_color(left-2,top-2,length+2,top+15+2,color);
	}
};

class CommandButton
{
	private:

	float capyes;
	char* caption;
	int left,top,right,bottom;
	int length;

	public:

	void Show(int l,int t)
	{
		int width;
		setfillstyle(SOLID_FILL,butcolor);
		settextstyle(SMALL_FONT,HORIZ_DIR,4);
		if(capyes==0)
		{
			width=(strlen(caption)*8)+5;
			length=width+l;
		}
		else
		{
			width=(strlen("GCPPCommand")*8)+5;
			length=width+l;
		}
		int height=60;
		int r=l+width;
		int b=t+25;
		bar(l,t,r,b);
		setcolor(15);
		line(l+1,t,r,t);
		line(l+1,t+1,l+1,b-1);
		setcolor(8);
		line(l+1,b-1,r,b-1);
		line(r,t,r,b-1);
		setcolor(0);
		line(l,b,r+1,b);
		line(r+1,t+1,r+1,b);
		if(capyes==0)
		outtextxy(l+10,t+7,caption);
		else
		outtextxy(l+10,t+7,"GCPPCommand");
		left=l,top=t,right=r,bottom=b;
	}

	void Show(int l,int t,char *cap)
	{
		int width;
		setfillstyle(SOLID_FILL,butcolor);
		settextstyle(SMALL_FONT,HORIZ_DIR,4);
		width=(strlen(cap)*8)+5;
		length=width+l;
		int height=60;
		int r=l+width;
		int b=t+25;
		bar(l,t,r,b);
		setcolor(15);
		line(l+1,t,r,t);
		line(l+1,t+1,l+1,b-1);
		setcolor(8);
		line(l+1,b-1,r,b-1);
		line(r,t,r,b-1);
		setcolor(0);
		line(l,b,r+1,b);
		line(r+1,t+1,r+1,b);
		outtextxy(l+10,t+7,cap);
		left=l,top=t,right=r,bottom=b;
	}

	int Click()
	{
		showmouse();
		while(!kbhit())
		{
			getmouse(button,x,y);
			if((x>left)&&(x<right)&&(y>top)&&(y<bottom)&&(button==1))
			{
				hidemouse();
				buttonclick(left,top,right,bottom);
				showmouse();
				delay(50);
				hidemouse();
				buttoneffect(left,top,right,bottom);
				showmouse();
				delay(200);
				return 1;
			}
		}
	}

	Keypress()
	{
		while(1)
		{
			int in;
			in=inkey();

			if(in==13)
			{
				buttonclick(left,top,right,bottom);
				delay(50);
				buttoneffect(left,top,right,bottom);
				return 1;
				break;
			}

			if(in==27||in==9)
			{
				return -1;
				break;
			}
		}
	}

	void Caption(char* cap)
	{
		strcpy(caption,cap);
		capyes=0;
	}

	Getrightpos()
	{
		return length;
	}

	void Selection(int color)
	{
		select_with_color(left-2,top-2,length+4,bottom+2,color);
	}

	void Deselection(int color)
	{
		deselect_with_color(left-2,top-2,length+4,bottom+2,color);
	}
};

class Form
{
	private:

	int backcolor,backcolyes;
	int barcolor,barcolyes;
	int capcolor,capcolyes;
	int left,top,right,buttom;
	int appearance;
	char fn[80],*caption;
	int capyes;
	int closebutyes;

	public:

	void Show(int l,int t,int r,int b,char* cap,char file[80])
	{
		back(l,t,r+2,b+2,0,file);
		setfillstyle(SOLID_FILL,7);
		bar(l,t,r,b);
		setfillstyle(SOLID_FILL,1);
		bar(l+3,t+3,r-3,t+23);
		setcolor(15);
		settextstyle(SMALL_FONT,HORIZ_DIR,4);
		outtextxy(l+8,t+8,cap);
		setcolor(15);
		line(l+1,t,r,t);
		line(l+1,t+1,l+1,b-1);
		setcolor(8);
		line(l+1,b-1,r,b-1);
		line(r,t,r,b-1);
		setcolor(0);
		line(l,b,r+1,b);
		line(r+1,t+1,r+1,b);
		buttonon(r-20,t+5,r-5,t+20,"X",3);

		left=l,top=t,right=r,buttom=b;
		strcpy(fn,file);
	}

	void Show(int l,int t,int r,int b,char file[80])
	{
		back(l,t,r+2,b+2,0,file);
		if(backcolyes==0)
		setfillstyle(SOLID_FILL,backcolor);
		else
		setfillstyle(SOLID_FILL,7);
		bar(l,t,r,b);
		if(barcolyes==0)
		setfillstyle(SOLID_FILL,barcolor);
		else
		setfillstyle(SOLID_FILL,1);
		bar(l+3,t+3,r-3,t+23);
		if(capcolyes==0)
		setcolor(capcolor);
		else
		setcolor(15);
		settextstyle(SMALL_FONT,HORIZ_DIR,4);
		if(capyes==-1)
		outtextxy(l+8,t+8,caption);
		else
		outtextxy(l+8,t+8,"GCPPForm");
		setcolor(15);
		line(l+1,t,r,t);
		line(l+1,t+1,l+1,b-1);
		setcolor(8);
		line(l+1,b-1,r,b-1);
		line(r,t,r,b-1);
		setcolor(0);
		line(l,b,r+1,b);
		line(r+1,t+1,r+1,b);
		if(closebutyes!=0)
		buttonon(r-20,t+5,r-5,t+20,"X",3);
		left=l,top=t,right=r,buttom=b;
		strcpy(fn,file);
	}

	int FormSelect()
	{
		int val=3;
		showmouse();
		while(1)
		{
			getmouse(button,x,y);
			if((x>=left)&&(x<=right)&&(y>=top)&&(y<=buttom)&&(button==1))
			{
				val=1;
				break;
			}
			else
			{
				val=0;
				break;
			}
		}
		return val;
	}

	Clickclose()
	{
		showmouse();
		while(!kbhit())
		{
			getmouse(button,x,y);
			if((x>right-20)&&(x<right-5)&&(y>top+5)&&(y<top+20)&&(button==1))
			{
				hidemouse();
				back(left,top,right+2,buttom+2,1,fn);
				showmouse();
				return 1;
				break;
			}
			else
			{
				return -1;
				break;
			}
		}
	}

	Keypressclose()
	{
		int in;
		in=getscan();

		while(1)
		{
			if(in==107)
			{
				back(left,top,right+2,buttom+2,1,fn);
				return 1;
				break;
			}
			else
			{
				return -1;
				break;
			}
		}
	}

	void Hide()
	{
		back(left,top,right+2,buttom,1,fn);

	}

	void Caption(char* cap)
	{
		strcpy(caption,cap);
		capyes=-1;
	}

	void Backcolor(int bkcolor)
	{
		backcolor=bkcolor;
		backcolyes=0;
	}

	void Barcolor(int brcolor)
	{
		barcolor=brcolor;
		barcolyes=0;
	}

	void Capcolor(int color)
	{
		capcolor=color;
		capcolyes=0;
	}

	void Appearance(int app)
	{
		if(app==0)
		appearance=0;
		if(app>1)
		MsgBox("Invalid property value. Please enter 0 for flat or 1 for 3D form","Error calling Appearance",CRITICAL);
	}

	void CloseButton(int onoff)
	{
		if(onoff==0)
		closebutyes=0;
		if(onoff==1)
		closebutyes=1;
	}
};

class ListBox
{
	private:

	int l,t,r,b,btop,bbottom,length;
	int row;

	public:

	void List(int left,int top,char*list[],int rows)
	{

		int h=((rows*15)+10);
		int s=1,size;

		settextstyle(2,0,4);
		for ( int i = 0 ; i < rows ; i++ )
		{
			if ( strlen ( list[i] ) > s )
			{
				s = strlen ( list[i] ) ;
				s=s;
			}
		}
		s=s*8;
		size=s;
		int w=size;
		length=w;
		setfillstyle(1,15);
		bar(left,top,left+w,top+h);
		buttonclick(left,top,left+w,top+h);
		settextstyle(2,HORIZ_DIR,4);
		setcolor(0);
		for(int a=0;a<rows;a++)
			outtextxy(left+3,(top+2+(a*15)),list[a]);

		l=left,t=top,r=left+w,b=top+h;
		btop=t;bbottom=btop+15;
		row=rows;
	}

	void ShowForKey(int left,int top,char*list[],int rows)
	{

		int h=((rows*15)+10);
		int s=1,size;

		settextstyle(2,0,4);
		for ( int i = 0 ; i < rows ; i++ )
		{
			if ( strlen ( list[i] ) > s )
			{
				s = strlen ( list[i] ) ;
				s=s;
			}
		}
		s=s*8;
		size=s;
		int w=size;
		length=w;
		setfillstyle(1,15);
		bar(left,top,left+w,top+h);
		buttonclick(left,top,left+w,top+h);
		settextstyle(2,HORIZ_DIR,4);
		setcolor(0);
		for(int a=0;a<rows;a++)
			outtextxy(left+3,(top+2+(a*15)),list[a]);

		l=left,t=top,r=left+w,b=top+h;
		btop=t;bbottom=btop+15;
		row=rows;
		invertcolors(l+2,t+2,r-3,t+15);
	}

	int Show(int xc1,int yc1,char *list[],int rows)
	{
		hidemouse();
		int h=((rows*15)+10);
		int s=1,size;

		settextstyle(2,0,4);
		for ( int i = 0 ; i < rows ; i++ )
		{
			if ( strlen ( list[i] ) > s )
			{
				s = strlen ( list[i] ) ;
				s=s;
			}
		}
		s=s*8;
		size=s;
		int w=size;
		length=w;
		setfillstyle(1,15);
		bar(xc1,yc1,xc1+w,yc1+h);
		buttonclick(xc1,yc1,xc1+w,yc1+h);
		settextstyle(2,HORIZ_DIR,4);
		setcolor(0);
		for(int a=0;a<rows;a++)
			outtextxy(xc1+3,(yc1+2+(a*15)),list[a]);
		showmouse();
		getmouse(button,x,y);
		int lc=1,fnc=0,over=-1;
		delay(50);
		while(lc==1)
		{
			getmouse(button,x,y);
			for(int b=0;b<rows;b++)
			{
				if(button==1)
				{
					if((x>xc1+w)||(x<xc1)||(y>yc1+h)||(y<yc1))
					{
						fnc=0;lc=0;
					}
					else if((y>(yc1+(15*b)))&&(y<(yc1+(15*b)+15)))
					{
						fnc=b+1;lc=0;
					}
				}
				if(button==0)
				{
					if((y>(yc1+(15*b)))&&(y<(yc1+(15*b)+15)))
					{
						if((b!=over)||(over==-1))
						{
							if(over!=-1)
							{
								invertcolors(xc1+2,yc1+(15*over)+1,xc1+w-2,yc1+(15*over)+13);
							}
							invertcolors(xc1+2,yc1+(15*b)+1,xc1+w-2,yc1+(15*b)+13);over=b;
						}
						over=b;
					}
				}
			}
		}
		hidemouse();
		showmouse();
		return(fnc);
	}

	int Keypress()
	{
		static int counter=0;
		static int scrollup=0;
		static int scrolldown=0;
		int scrolltime=row;

		while(1)
		{
			int in,ret;
			in=inkey();

			if(in==72)
			{
				if(scrollup>0)
				{
					scrollup--;
					invertcolors(l+2,btop+2,r-3,bbottom);
					btop=btop-15;
					bbottom=bbottom-15;
					invertcolors(l+2,btop+2,r-3,bbottom);
					scrolldown=scrollup;
					counter=scrollup;
					return scrollup+1;
				}
			}

			if(in==80)
			{
				if(scrolldown<scrolltime-1)
				{
					scrolldown++;
					counter++;
					invertcolors(l+2,btop+2,r-3,bbottom);
					btop=btop+15;
					bbottom=bbottom+15;
					invertcolors(l+2,btop+2,r-3,bbottom);
					scrollup=counter;
					ret=scrolldown+1;
					counter=scrolldown;
					return ret;
				}
			}
			if(in==13)
			{
				counter=0;
				scrolldown=0;
				scrollup=0;
				return -1;
				break;
			}

		}
		counter=0;
		scrolldown=0;
	}

	Getrightpos()
	{
		return length;
	}
};

class HorizScrollBar
{
	private:

	int left,top,right,bottom;
	int bleft,bright;
	int scrolltime,scount;

	public:

	int Show(int l,int t,int r,int scroll)
	{
		setfillstyle(1,15);
		bar(l,t,r,t+20);
		setfillstyle(9,7);
		bar(l,t,r,t+20);

		/* Left button */
		mybutton(l,t,l+15,t+20);

		int b=t+20;
		int ll,lt,lr,lb;
		ll=l+9,lt=t+6,lr=l+9,lb=b-6;
		for(int i=0;i<=4;i++)
		{
			setcolor(0);
			line(ll,lt,lr,lb);
			ll=ll-1,lr=lr-1;
			lt=lt+1,lb=lb-1;
		}

		/* Right button */
		int topoflowerbutton;
		topoflowerbutton=r-15;
		mybutton(r-15,t,r,b);

		ll=r-9,lt=t+6,lr=r-9,lb=b-6;
		for(int j=0;j<=4;j++)
		{
			setcolor(0);
			line(ll,lt,lr,lb);
			ll=ll+1,lr=lr+1;
			lt=lt+1,lb=lb-1;
		}

		static int barleft,barright;
		b=t+20;
		topoflowerbutton=r-15;
		barleft=l+16;
		barright=((topoflowerbutton-1)-(scroll*5));
		back(barleft,t,barright,b,0);
		mybutton(barleft,t,barright,b);
		bleft=barleft,bright=barright;
		left=l,top=t,right=r,bottom=b;
		scrolltime=scroll;
	}
	int Click()
	{
		static int counter=0;
		static int scrollleft=0;
		static int scrollright=0;

		showmouse();
		while(!kbhit())
		{
			getmousepos(&button,&x,&y);
			if((x>left)&&(x<left+15)&&(y>top)&&(y<bottom))
			{
				if((button & 1)==1)
				{
					if(scrollleft>0)
					{
						scrollleft--;
						hidemouse();
						back(bleft,top,bright,bottom,1);
						showmouse();
						bleft=bleft-5;
						bright=bright-5;
						hidemouse();
						back(bleft,top,bright,bottom,0);
						mybutton(bleft,top,bright,bottom);
						showmouse();
						delay(200);
						scrollright=scrollleft;
						counter=scrollleft;
						return scrollleft;
					}
				}
			}

			if((x>right-15)&&(x<right)&&(y>top)&&(y<bottom))
			{
				if((button & 1)==1)
				{
					if(scrollright<scrolltime)
					{
						scrollright++;
						counter++;
						hidemouse();
						back(bleft,top,bright,bottom,1);
						showmouse();
						bleft=bleft+5;
						bright=bright+5;
						hidemouse();
						back(bleft,top,bright,bottom,0);
						mybutton(bleft,top,bright,bottom);
						showmouse();
						delay(200);
						scrollleft=counter;
						return scrollright;
					}
				}
			}
		}
	}

	int Keypress()
	{
		static int counter=0;
		static int scrollleft=0;
		static int scrollright=0;

		while(1)
		{
			int in;
			in=inkey();

			if(in==75)
			{
				if(scrollleft>0)
				{
					scrollleft--;
					back(bleft,top,bright,bottom,1);
					bleft=bleft-5;
					bright=bright-5;
					back(bleft,top,bright,bottom,0);
					mybutton(bleft,top,bright,bottom);
					scrollright=scrollleft;
					counter=scrollleft;
					return scrollleft;
				}
			}

			if(in==77)
			{
				if(scrollright<scrolltime)
				{
					scrollright++;
					counter++;
					back(bleft,top,bright,bottom,1);
					bleft=bleft+5;
					bright=bright+5;
					back(bleft,top,bright,bottom,0);
					mybutton(bleft,top,bright,bottom);
					scrollleft=counter;
					return scrollright;
				}
			}

			if(in==13)
			{
			return -1;
			break;
			}
		}
	}

	void Selection(int color)
	{
		select_with_color(left-2,top-2,right+2,bottom+2,color);
	}

	void Deselection(int color)
	{
		deselect_with_color(left-2,top-2,right+2,bottom+2,color);
	}
};

class VertScrollBar
{
	private:

	int left,top,right,bottom;
	int btop,bbottom;
	int scrolltime,scount;
	int diff;

	public:

	int Show(int l,int t,int b,int scroll)
	{
		setfillstyle(1,15);
		bar(l,t,l+20,b);
		setfillstyle(9,7);
		bar(l,t,l+20,b);

		/* Upper button */
		mybutton(l,t,l+20,t+15);
		int ll,lt,lr,lb,r=l+20;
		ll=l+6,lt=t+9,lr=r-6,lb=lt;
		for(int i=0;i<=4;i++)
		{
			setcolor(0);
			line(ll,lt,lr,lb);
			ll=ll+1,lr=lr-1;
			lt=lt-1,lb=lb-1;
		}

		/* Lower button */
		int topoflowerbutton;
		topoflowerbutton=b-15;
		mybutton(l,b-15,r,b);
		ll=l+6,lt=b-10,lr=r-6,lb=lt;
		for(int j=0;j<=4;j++)
		{
			setcolor(0);
			line(ll,lt,lr,lb);
			ll=ll+1,lr=lr-1;
			lt=lt+1,lb=lb+1;
		}
		static int bartop,barbottom;
		r=l+20;
		topoflowerbutton=b-15;
		bartop=t+16;
		barbottom=((topoflowerbutton-1)-(scroll*5));

		int diffbar;
		diffbar=barbottom-bartop;

		if(diffbar>=5)
		{
		back(l,bartop,r,barbottom,0);
		mybutton(l,bartop,r,barbottom);
		btop=bartop,bbottom=barbottom;
		}

		diff=diffbar;
		left=l,top=t,right=r,bottom=b;
		scrolltime=scroll;
	}

	int Click()
	{
		static int counter=0;
		static int scrollup=0;
		static int scrolldown=0;
		showmouse();
		while(!kbhit())
		{
			getmousepos(&button,&x,&y);
			if((x>left)&&(x<right)&&(y>top)&&(y<top+15))
			{
				if((button & 1)==1)
				{
					if(scrollup>0&&diff>=5)
					{
						scrollup--;
						hidemouse();
						back(left,btop,right,bbottom,1);
						showmouse();
						btop=btop-5;
						bbottom=bbottom-5;
						hidemouse();
						back(left,btop,right,bbottom,0);
						mybutton(left,btop,right,bbottom);
						showmouse();
						delay(200);
						scrolldown=scrollup;
						counter=scrollup;
						return scrollup;
					}

					if(scrollup>0&&diff<5)
					{
						scrollup--;
						btop=btop-5;
						bbottom=bbottom-5;
						delay(200);
						scrolldown=scrollup;
						counter=scrollup;
						return scrollup;
					}
				}
			}

			if((x>left)&&(x<right)&&(y>bottom-15)&&(y<bottom))
			{
				if((button & 1)==1)
				{
					if(scrolldown<scrolltime&&diff>=5)
					{
						scrolldown++;
						counter++;
						hidemouse();
						back(left,btop,right,bbottom,1);
						showmouse();
						btop=btop+5;
						bbottom=bbottom+5;
						hidemouse();
						back(left,btop,right,bbottom,0);
						mybutton(left,btop,right,bbottom);
						showmouse();
						delay(200);
						scrollup=counter;
						return scrolldown;
					}

					if(scrolldown<scrolltime&&diff<5)
					{
						scrolldown++;
						counter++;
						btop=btop+5;
						bbottom=bbottom+5;
						delay(200);
						scrollup=counter;
						return scrolldown;
					}
				}
			}
		}
	}

	int Keypress()
	{
		static int counter=0;
		static int scrollup=0;
		static int scrolldown=0;

		while(1)
		{
			int in;
			in=inkey();
			if(in==72)
			{
				if(scrollup>0&&diff>=5)
				{
					scrollup--;
					back(left,btop,right,bbottom,1);
					btop=btop-5;
					bbottom=bbottom-5;
					back(left,btop,right,bbottom,0);
					mybutton(left,btop,right,bbottom);
					scrolldown=scrollup;
					counter=scrollup;
					return scrollup;
				}

				if(scrollup>0&&diff<5)
				{
					scrollup--;
					btop=btop-5;
					bbottom=bbottom-5;
					scrolldown=scrollup;
					counter=scrollup;
					return scrollup;
				}
			}

			if(in==80)
			{
				if(scrolldown<scrolltime&&diff>=5)
				{
					scrolldown++;
					counter++;
					back(left,btop,right,bbottom,1);
					btop=btop+5;
					bbottom=bbottom+5;
					back(left,btop,right,bbottom,0);
					mybutton(left,btop,right,bbottom);
					scrollup=counter;
					return scrolldown;
				}

				if(scrolldown<scrolltime&&diff<5)
				{
					scrolldown++;
					counter++;
					btop=btop+5;
					bbottom=bbottom+5;
					scrollup=counter;
					return scrolldown;
				}
			}

			if(in==13)
			{
				return -1;
				break;
			}
		}
	}

	void Selection(int color)
	{
		select_with_color(left-2,top-2,right+2,bottom+2,color);
	}

	void Deselection(int color)
	{
		deselect_with_color(left-2,top-2,right+2,bottom+2,color);
	}
};

class PopupMenu
{
	private:

	int l,t,r,b,btop,bbottom,length;
	int row;

	public:

	void Show(int left,int top,char*list[],int rows)
	{

		int h=((rows*15)+10);
		int s=1,size;

		settextstyle(2,0,4);
		for ( int i = 0 ; i < rows ; i++ )
		{
			if ( strlen ( list[i] ) > s )
			{
				s = strlen ( list[i] ) ;
				s=s;
			}
		}
		s=s*8;
		size=s;
		int w=size;
		length=w;

		back(left,top,left+w+30,top+h,0);

		setfillstyle(1,7);
		bar(left,top,left+w,top+h);
		buttoneffect(left,top,left+w,top+h);
		settextstyle(2,HORIZ_DIR,4);
		setcolor(0);
		for(int a=0;a<rows;a++)
			outtextxy(left+3,(top+2+(a*15)),list[a]);

		l=left,t=top,r=left+w,b=top+h;
		btop=t;bbottom=btop+15;
		row=rows;
		invertcolors(l+2,t+2,r-3,t+15);
	}

	int Click()
	{
		hidemouse();
		invertcolors(l+2,t+2,r-3,t+15);
		int h=((row*15)+10);
		int s=1,size;

		settextstyle(2,0,4);
		for ( int i = 0 ; i < row ; i++ )
		{
			if ( strlen ( list[i] ) > s )
			{
				s = strlen ( list[i] ) ;
				s=s;
			}
		}
		s=s*8;
		size=s;
		int w=size;
		length=w;

		//back(l,t,l+w,t+h,0);

		showmouse();
		getmouse(button,x,y);
		int lc=1,fnc=0,over=-1;
		delay(50);
		while(lc==1)
		{
			getmouse(button,x,y);
			for(int b=0;b<row;b++)
			{
				if(button==1)
				{
					if((x>l+w)||(x<l)||(y>t+h)||(y<t))
					{
						fnc=0;lc=0;
					}
					else if((y>(t+(15*b)))&&(y<(t+(15*b)+15)))
					{
						fnc=b+1;lc=0;
					}
				}
				if(button==0)
				{
					if((y>(t+(15*b)))&&(y<(t+(15*b)+15)))
					{
						if((b!=over)||(over==-1))
						{
							if(over!=-1)
							{
								invertcolors(l+2,t+(15*over)+1,l+w-2,t+(15*over)+13);
							}
							invertcolors(l+2,t+(15*b)+1,l+w-2,t+(15*b)+13);over=b;
						}
						over=b;
					}
				}
			}
		}
		hidemouse();

		back(l,t,l+w+30,t+h,1);
		delay(100);
		showmouse();

		return(fnc);
	}

	int Keypress()
	{
		static int counter=0;
		static int scrollup=0;
		static int scrolldown=0;
		int scrolltime=row;

		int h=((row*15)+10);
		int s=1,size;
		int retval=1;

		settextstyle(2,0,4);
		for ( int i = 0 ; i < row ; i++ )
		{
			if ( strlen ( list[i] ) > s )
			{
				s = strlen ( list[i] ) ;
				s=s;
			}
		}
		s=s*8;
		size=s;
		int w=size;
		//length=w;

		while(1)
		{
			int in,ret;
			in=getscan();

			if(in==72)
			{
				if(scrollup>0)
				{
					scrollup--;
					invertcolors(l+2,btop+2,r-3,bbottom);
					btop=btop-15;
					bbottom=bbottom-15;
					invertcolors(l+2,btop+2,r-3,bbottom);
					scrolldown=scrollup;
					counter=scrollup;
					retval=scrollup+1;
					//return scrollup+1;
				}
			}

			if(in==80)
			{
				if(scrolldown<scrolltime-1)
				{
					scrolldown++;
					counter++;
					invertcolors(l+2,btop+2,r-3,bbottom);
					btop=btop+15;
					bbottom=bbottom+15;
					invertcolors(l+2,btop+2,r-3,bbottom);
					scrollup=counter;
					ret=scrolldown+1;
					counter=scrolldown;
					retval=ret;
					//return ret;
				}
			}
			if(in==28)
			{
				counter=0;
				scrolldown=0;
				scrollup=0;
				back(l,t,l+length+30,t+h,1);
				return retval;
				break;
			}

			if(in==1)
			{
				counter=0;
				scrolldown=0;
				scrollup=0;
				back(l,t,l+length+30,t+h,1);
				return 0;
				break;
			}

		}

		counter=0;
		scrolldown=0;
	}

	Getrightpos()
	{
		return length;
	}
};

class ComboBox
{
	private:

		int l,t,r,b,btop,bbottom,length;
		int row;
		int textyes;
		char* combo_text;

	public:

		void Text(char* comtext)
		{
			combo_text=comtext;
			textyes=1;
		}

		int KShow(int left,int top,char *list[],int rows)
		{
			ComboMenu combolist;
			int s=1,st=1;static int ii,count;
			int size=0,buttonleft=0;
			char *select;
			int takeret;

			if(textyes==1)
			select=combo_text;
			else
			select=list[0];

			settextstyle(2,0,4);
			for ( int i = 0 ; i < rows ; i++ )
			{
				if ( strlen ( list[i] ) > s )
				{
					s = strlen ( list[i] ) ;
					s=s;
				}
			}

			s=s*8;
			size=s+30;
			buttonleft=size;
			size=size/8;

			if(count!=1)
			textarea(select,left,top,size);

			int ml=left,mt=top,mr=left+buttonleft-6,mb=top+14;
			int ll=mr-12,lt=mt+6,lr=mr-7,lb=mt+6; //for lines in mybutton to create arrow.

			mybutton(mr-16,mt+1,mr-2,mb-1);
			for(int j=0;j<=2;j++)
			{
				setcolor(0);
				line(ll,lt,lr,lb);
				ll=ll+1,lr=lr-1;
				lt=lt+1,lb=lb+1;
			}

			l=left,t=top,r=left+size;
			btop=t;bbottom=btop+15;
			row=rows;

			while(1)
			{
				int in,ret=1;
				in=getch();
				if(in==13)
				{
					combolist.Show(left,top+18,list,rows);
					while(1)
					{
						takeret=ret;
						ret=combolist.Keypress(list);
						if(ret==-1)
						{
							select=list[takeret-1];
							textarea(select,left,top,size);
							int ml=l,mt=t,mr=l+buttonleft-6,mb=t+14;
							int ll=mr-12,lt=mt+6,lr=mr-7,lb=mt+6; //for lines in mybutton to create arrow.

							mybutton(mr-16,mt+1,mr-2,mb-1);
							for(int j=0;j<=2;j++)
							{
								setcolor(0);
								line(ll,lt,lr,lb);
								ll=ll+1,lr=lr-1;
								lt=lt+1,lb=lb+1;
							}
							break;
						}
					}
					break;
				}
			}
			return takeret;
		}

		int MShow(int l,int t,char *list[],int row)
		{
			int s=1,st=1;static int ii,count;
			int size=0,buttonleft=0;
			int ret;
			char *greater;
			char *select;

			if(textyes==1)
			select=combo_text;
			else
			select=list[0];

			for ( int i = 0 ; i < row ; i++ )
			{
				if ( strlen ( list[i] ) > s )
				{
					s = strlen ( list[i] ) ;
					s=s;
				}
			}

			s=s*8;
			size=s+30;
			buttonleft=size;
			size=size/8;

			if(count!=1)
			textarea(select,l,t,size);

			int ml=l,mt=t,mr=l+buttonleft-6,mb=t+14;
			int ll=mr-12,lt=mt+6,lr=mr-7,lb=mt+6; //for lines in mybutton to create arrow.

			mybutton(mr-16,mt+1,mr-2,mb-1);
			for(int j=0;j<=2;j++)
			{
				setcolor(0);
				line(ll,lt,lr,lb);
				ll=ll+1,lr=lr-1;
				lt=lt+1,lb=lb+1;
			}

			showmouse();

			while(!kbhit())
			{
				getmouse(button,x,y); //Get Mouse
				if((x>ml)&&(x<mr)&&(y>mt)&&(y<mb)&&(button==1))
				{
					delay(200);
					ret=mymenu(ml-2,mt+18,list,6,size-1);
					for(ii=1;ii<=row;ii++)
					{
						if(ii==ret)
						{
							select=list[ii-1];
							count=1;
						}
					}

					textarea(select,l,t,size);
					int ml=l,mt=t,mr=l+buttonleft-6,mb=t+14;
					int ll=mr-12,lt=mt+6,lr=mr-7,lb=mt+6; //for lines in mybutton to create arrow.

					mybutton(mr-16,mt+1,mr-2,mb-1);
					for(int j=0;j<=2;j++)
					{
						setcolor(0);
						line(ll,lt,lr,lb);
						ll=ll+1,lr=lr-1;
						lt=lt+1,lb=lb+1;
					}
					return ret;
				}
			}
		}
};

class IconButton
{
	private:

	float capyes;
	char* caption;
	int left,top,right,bottom;
	int length;

	public:

	void Show(int l,int t,char fn[100])
	{
		int width;
		settextstyle(2,0,4);
		int length;
		int lengthdiff,minus,devide;
		if(capyes==0)
		{
			width=(textwidth(caption));
			length=width+20;
		}
		else
		{
			width=(textwidth("GCPPCommand"));
			length=width+20;
		}

		if(length<=50)
		{
			mybutton(l,t,l+50,t+50);
			load_icon(fn,l+5,t+5);
			left=l,top=t,right=l+50,bottom=t+50;
		}
		if(length>50)
		{
			lengthdiff=((l+length)-l);
			minus=length-40;
			devide=minus/2;
			mybutton(l,t,l+length,t+50);
			load_icon(fn,l+devide,t+5);
			left=l,top=t,right=l+length,bottom=t+50;
		}
		setfillstyle(SOLID_FILL,butcolor);
		settextstyle(SMALL_FONT,HORIZ_DIR,4);
		setcolor(0);
		if(capyes==0)
		outtextxy(l+10,t+37,caption);
		else
		outtextxy(l+10,t+37,"GCPPCommand");
	}

	void Show(int l,int t,char *cap,char fn[100])
	{
		int width;
		settextstyle(2,0,4);
		int length;
		int lengthdiff,minus,devide;
		length=textwidth(cap)+10;
		if(length<=50)
		{
			mybutton(l,t,l+50,t+50);
			load_icon(fn,l+5,t+5);
			left=l,top=t,right=l+50,bottom=t+50;
		}
		if(length>50)
		{
			lengthdiff=((l+length)-l);
			minus=length-40;
			devide=minus/2;
			mybutton(l,t,l+length,t+50);
			load_icon(fn,l+devide,t+5);
			left=l,top=t,right=l+length,bottom=t+50;
		}
		setcolor(0);
		settextstyle(2,0,4);
		outtextxy(l+5,t+37,cap);
	}

	Click()
	{
		showmouse();
		while(!kbhit())
		{
			getmouse(button,x,y);
			if((x>left)&&(x<right)&&(y>top)&&(y<bottom)&&(button==1))
			{
				hidemouse();
				buttonclick(left,top,right,bottom);
				showmouse();
				delay(50);
				hidemouse();
				buttoneffect(left,top,right,bottom);
				showmouse();
				delay(200);
				return 1;
			}
		}
	}

	Keypress()
	{
		while(1)
		{
			int in;
			in=inkey();

			if(in==13)
			{
				buttonclick(left,top,right,bottom);
				delay(50);
				buttoneffect(left,top,right,bottom);
				return 1;
				break;
			}

			if(in==27||in==9)
			{
				return -1;
				break;
			}
		}
	}

	void Caption(char* cap)
	{
		strcpy(caption,cap);
		capyes=0;
	}

	Getrightpos()
	{
		return length;
	}

	void Selection(int color)
	{
		select_with_color(left-2,top-2,right+2,bottom+2,color);
	}

	void Deselection(int color)
	{
		deselect_with_color(left-2,top-2,right+2,bottom+2,color);
	}
};

class ScrollList
{
	private:

	int l,t,r,b,gr,disp;

	public:

	VertScrollBar vert1;

	Show(int left,int top,char *list[],int totalline,int displine)
	{
		int s=1,width,height;
		int ghurbe,vertscroll;
		int row,col;

		ghurbe=totalline-displine;
		if(ghurbe>0)
		vertscroll=ghurbe;
		else
		vertscroll=0;

		settextstyle(2,0,4);
		row=left-8+10;
		col=top-8+5;

		for ( int i = 0 ; i < totalline ; i++ )
		{
			if ( strlen ( list[i] ) > s )
			{
				s = strlen ( list[i] ) ;
				s=s;
			}
		}
		s=s*8;
		width=s;

		height=displine*10;

		setfillstyle(1,15);
		bar(left-10,top-10,left+width+30,top+height+10);
		buttonclick(left-10,top-10,left+width+30,top+height+10);
		vert1.Show(left+width+8,top-9,top+height+8,vertscroll);

		for(i=0;i<displine;i++)
		{
			setcolor(0);
			outtextxy(row,col,list[i]);
			col+=10;
		}

		l=left-8,t=top-8,r=left+width+5,b=top+height+5;
		gr=vertscroll;
		disp=displine;
	}

	Clear()
	{
		setfillstyle(1,15);
		bar(l,t,r,b);
	}

	Keypress(char *list[])
	{
		int first=0,ret,i;
		int row=l+10,col=t+5;

		settextstyle(2,0,4);

		while(1)
		{
			ret=vert1.Keypress();
			if((ret<=gr||ret>=0)&&ret!=-1)
			{
				first=ret;
				setfillstyle(1,15);
				bar(l,t,r,b);

				setcolor(0);
				for(i=first;i<first+disp;i++)
				{
					outtextxy(row,col,list[i]);
					col+=10;
				}
				col=t;
			}

			if(ret==-1)
			return 0;
		}
	}

	Click(char *list[])
	{
		int first=0,ret,i;
		int row=l+10,col=t+5;

		settextstyle(2,0,4);

		showmouse();
		while(!kbhit())
		{
			ret=vert1.Click();
			if((ret<=gr||ret>=0)&&ret!=-1)
			{
				first=ret;
				setfillstyle(1,15);
				bar(l,t,r,b);

				setcolor(0);
				for(i=first;i<first+disp;i++)
				{
					outtextxy(row,col,list[i]);
					col+=10;
				}
				col=t;
			}

			if(ret==-1)
			return 0;
		}
	}
};

class Menu
{

	private:

	int pl,pt,pr,pb,item;

	public:

	int Show(int l,int t,char *list[],int row)
	{
		int s=1,st=1;static int ii,count;
		int size=0,buttonleft=0;
		int length=0,total_text_size=0;
		int left=l;
		int stat_left=l;

		pl=l,pt=t;
		item=row;

		settextstyle(SMALL_FONT,HORIZ_DIR,4);

		for ( int i = 0 ; i < row ; i++ )
		{
			length=strlen ( list[i] );
			size=size+length;
		}

		total_text_size=size*8;

		setfillstyle(1,7);
		bar(l,t,l+total_text_size,t+15);

		int temp=0;
		setcolor(0);
		for ( i = 0 ; i < row ; i++ )
		{
			outtextxy(left+4,t+2,list[i]);
			length=strlen ( list[i] );
			size=length*8;
			temp=size;
			left=temp+left;
			size=0;length=0;
		}
	}

	Keypress(char* list[])
	{
		int in;
		int tl,ttl,ttl2;
		int count=0,lasttake=0;
		int len,len2,len3;
		int lastright,lastleft;
		int i;

		tl=pl;

		while(1)
		{
			in=getscan();

			if(in==28)
			{
				if(count==0)
				{
					len2=strlen(list[item-1])*8;
					buttonpush(ttl,pt,ttl+len2,pt+15,0);
				}
				len2=strlen(list[count-1])*8;
				buttonpush(ttl,pt,ttl+len2,pt+15,0);
				return lasttake;
				break;
			}

			if(in==1)
			{
				if(count==0)
				{
					len2=strlen(list[item-1])*8;
					buttonpush(ttl,pt,ttl+len2,pt+15,0);
				}
				len2=strlen(list[count-1])*8;
				buttonpush(ttl,pt,ttl+len2,pt+15,0);
				return 0;
				break;
			}

			lastright=pl;
			lastleft=pl;

			if(in==77&&count>=0&&count<item)
			{
				len=strlen(list[count])*8;

				if(count==0)
				{

					for(i=0;i<item;i++)
					{
						len2=strlen(list[i])*8;
						lastright=lastright+len2;
					}

					for(i=0;i<item-1;i++)
					{
						len2=strlen(list[i])*8;
						lastleft=lastleft+len2;
					}

					buttonpush(lastleft,pt,lastright,pt+15,0);
				}

				if(count>0)
				{
					len2=strlen(list[count-1])*8;
					buttonpush(ttl,pt,ttl+len2,pt+15,0);
				}

				buttonpush(tl,pt,tl+len,pt+15,1);
				ttl=tl;
				tl=tl+len;
				count++;
				lasttake=count;

				if(count==item)
				{
					lasttake=count;
					count=0;
					tl=pl;
				}
			}
		}
	}
};

1-on-1 Technical Mentorship

Want to master snippets like this?

Debasis Bhattacharjee offers direct mentorship sessions for developers looking to level up their code quality, architecture decisions, and production engineering skills. Two decades of real-world experience — no theory, just craft.