Skip to main content
MEMORY_ARCHIVE // GRAPHICAL C++ // TURBO C++

Graphical C++Programming Beyond the Command Line

Between 2002 and 2004, I spent countless hours experimenting with C and C++ — building graphics, mouse interfaces, colors, windows, buttons, text boxes and desktop-like applications inside the DOS environment.

TURBO C++ IDE F1-Help
FileEditSearchRun CompileDebugProjectOptions WindowHelp
═ GCPPMAIN.H ═
C:\TC\BIN> tc.exe hello.cpp Turbo C++ Version 3.0 Copyright (c) 1992 Borland International Compiling GCPPMAIN.H... Compiling GCPPFUNC.H... Linking... ===== GRAPHICAL C++ ARCHIVE ===== Library : GCPPFUNC.H + GCPPMAIN.H Author : Debasis Bhattacharjee Tool : Turbo C / Turbo C++ Target : DOS, EGA/VGA graphics Status : Source preserved. Reading archive... C:\TC\BIN> _
F2-Save F3-Load F5-Zoom F6-Switch F7-Trace F8-Step F9-Make F10-Menu Line 1 Col 1
§01 · Before Modern GUI Frameworks

Before Modern GUI Frameworks.

This archive documents work from the early 2000s, a period when DOS programming was still familiar territory and Turbo C / Turbo C++ was the standard teaching compiler in most Indian programming institutes. There was no Visual Studio IntelliSense, no npm install, no Stack Overflow. GUI development, in the modern sense, barely existed outside Windows itself — and even there, it meant the MFC and raw Win32 API, not the drag-and-drop toolkits of today.

If you wanted anything resembling a graphical interface inside DOS — windows, buttons, mouse-driven forms — you built it yourself, pixel by pixel, using low-level graphics calls and BIOS mouse interrupts. There was no framework to reach for. That constraint is exactly what this archive is about.

§02 · What I Called “Graphical C++”

What I Called “Graphical C++.”

I built a custom programming environment consisting of two header files:

#include <gcppfunc.h> #include <gcppmain.h>

These enabled mouse support, graphics initialization, color handling, drawing primitives, windows and panels, text boxes, buttons, and event handling — brought together into GUI-like, desktop-style interaction inside a DOS-based C/C++ programming environment.

“There are many different implementations possible through Turbo C and C++. Graphics programming is one of them. After a long time when I wrote different graphics programs through C, a question in my mind is always there that, are not we implement any user-friendly programs by which any programmer can develop GUI software in DOS? At that time I tried to complete a total solution of this.” — from the author's original notes on Graphical C++, written circa 2005

The goal was never to reproduce Windows itself — it was to bring graphical, desktop-style interaction into a DOS-based C/C++ programming environment. The author's own notes make this comparison directly: “Like many other GUI languages such as Visual Basic, Graphical C++ also provides many inbuilt graphical objects… these controls are very similar to Visual Basic's controls.” That framing — VB-like, DOS-native, not a Windows GUI framework — is the honest description used throughout this archive.

2
Header Files
4,268
Lines of Code
15
GUI-like Classes
~90
Standalone Functions

Line and class counts above are measured directly from the surviving source files. The author's own contemporary notes describe the library as “above 2500 lines of source code, over 50 different graphical objects and over 100 useful functions” — kept here as the original claim, alongside the verified current count.

§03 · The Core Library

The Graphical C++ Library.

Two header files powered everything. GCPPMAIN.H is the class layer — Form, Label, TextBox, CommandButton and the rest — and it includes GCPPFUNC.H directly, which holds the lower-level drawing, mouse and dialog functions those classes are built on. Getting started meant copying both files into the Turbo C folder and including only gcppmain.h in a program — it pulls in gcppfunc.h automatically.

Header 01 — GCPPFUNC.H

The foundation layer: mouse interrupt handling, graphics-mode initialization, low-level drawing primitives, dialog boxes (MsgBox, confirm, inputbox), popup menus, and color/palette routines including an HSI-to-RGB hue-wheel generator. This is the file's own opening comment, preserved exactly as written:

“Almost complete header file for creating greatest graphical objects ever using turbo c++”
COMPLETE SOURCE CODE · UNMODIFIED
GCPPFUNC.H 2,031 lines · 45,514 bytes
Download 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]='\0';
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]='\0';
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;
}
};
 

Header 02 — GCPPMAIN.H

The GUI class layer built on top of GCPPFUNC.H: Frame, Label, CheckBox, TextBox, CommandButton, Form, ListBox, HorizScrollBar, VertScrollBar, PopupMenu, ComboBox, IconButton, ScrollList, Menu and GeneralCombo — fifteen object-style controls in total, each with its own Show(), input and property methods, echoing the object model of Visual Basic.

COMPLETE SOURCE CODE · UNMODIFIED
GCPPMAIN.H 2,237 lines · 38,636 bytes
Download 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;
}
}
}
}
};
 
Archive note

Both files above are rendered directly from the original preserved .H files — the same bytes shown here are what the Download buttons deliver. Indentation, comments, variable names and old syntax are untouched.

§04 · What the Library Could Do

Why This Was Special.

Graphics

VGA/EGA graphics-mode initialization and drawing primitives — bars, lines, rectangles, filled shapes, pixel-level color manipulation.

  • graph() / svga() / highgraph()
  • invertcolors()
  • VGASetAllPalette()

Mouse

Direct BIOS mouse interrupt (INT 33h) handling — initialization, show/hide, position, click regions and custom cursor shapes.

  • initmouse() / showmouse() / hidemouse()
  • getmouse() / setmouse()
  • pointer() — custom cursor bitmaps

Colors

256-color VGA palette control, plus an HSI-to-RGB hue-wheel generator for demonstrating full-saturation color circles.

  • Hsi2Rgb()
  • AddColor()
  • Hue()

GUI-like Controls

Fifteen object-style classes covering forms, labels, buttons, text/password entry, checkboxes, combo and list boxes, scrollbars and menus.

  • Form, Label, TextBox, CommandButton
  • ListBox, ComboBox, CheckBox
  • HorizScrollBar, VertScrollBar, Menu

Event Handling

Polling-based click and key-region tracking so a program can react to a mouse click landing inside a specific button or link area.

  • getclick() / getlink()
  • activate()
  • inkey() / getscan()

Desktop-like Applications

Combining the above into multi-control, form-based programs — the closest DOS could get to a Windows-style application window.

  • openwindow() / openwindow2()
  • MsgBox() / confirm() / inputbox()
  • back() — save/restore screen regions

Every function and class named above appears verbatim in the source code in the section above — nothing here is a paraphrase of unseen behaviour.

§05 · Selected Graphical C++ Projects

Selected Graphical C++ Projects.

Project 01 · Complete application · Text mode · Turbo C · MS-DOS

DBMPS

Dos Base Multiperpose Software — November 2003 to January 2004

DBMPS is a menu-driven DOS program that gathers a file front end, a few small utilities and a command shell of its own under one roof. Its help screen dates it to 23 November 2003; the surviving files are timestamped between 25 November 2003 and 11 January 2004.

Everything on screen is drawn by the program itself. Characters are written straight into video memory at B800:0000, a window is a rectangle saved with savevideo() and put back with restorevideo(), and every menu runs through one routine, popupmenu(), fed with tables of strings.

Its executable, Dbmps.exe, is dated 11 January 2004, the same day as the last save of the source. The screens below are runtime captures, taken on 6 October 2026.

FIG. 01 Main menu Six entries; the highlighted letter in each is its hotkey. In the source the hotkey is marked with a caret — ^Welcome, ^File services, e^Xit DBMPS — and drawn in a second colour.
3,089
Lines of source
5
Source files
63,940
Bytes
13
Runtime screens

What is inside

There was no toolkit for DOS text mode to build on. The screens below stand on the six pieces that follow.

Screen layer

Text goes straight into video memory at B800:0000, two bytes per cell: the character and its colour. BIOS interrupts handle scrolling, mode changes, pixels and key scan codes.

  • printchar()
  • writestring()
  • clear()
  • getkeyscan()

Windows

A window is a rectangle of screen. savevideo() copies its characters and colours into a buffer before a box is drawn; restorevideo() puts them back. Boxes get a shadow band along the right and bottom edges, and frames use the double-line box characters.

  • savevideo()
  • restorevideo()
  • menubox()
  • drawbox()

Menus

One routine serves every menu. popupmenu() takes a table of strings, a position, a string of hotkeys and a help number, and returns the entry chosen; the status-bar line comes from a message table.

  • popupmenu()
  • getresponse()
  • displaymenu()
  • messages[]

Utilities

The expression calculator lives in DBMPS.c. The calendar, the world timer and the Shuffle puzzle each have a file of their own.

  • calcu()
  • calendar()
  • timer()
  • shuffle()

DOS.DEB

A command shell with insert and command modes, entered through Mydos: dos(), about two-fifths of DBMPS.c. Its own index command lists about forty commands.

  • mkdir
  • cd
  • find
  • attrib
  • freespace

Sound

DOS.DEB beeps as it starts. Its piano command maps keys to tones on the PC speaker with sound(), and nosound() silences each note after a short delay.

  • sound()
  • nosound()
  • sd()
  • sda()

Runtime screens

The main menu is above; the other 12 follow. Click any screen to enlarge it, then use the arrow keys to step through.

The shell
FIG. 02 Welcome The first menu entry. The words are the author’s own, spelling included: “It is very pleasant to me that you would like to use this software.”
FIG. 03 Help Help Topics lists five entries; in the surviving source only the first, DBMPS help, shows a screen. It dates the program: “It is on 23rd November 2003 developed.”
The menus
FIG. 04 File services Ten entries. Copy, Delete and Rename are wired up, calling filecopy(), del() and ren() from DOSFUNC.H. The six after them have no handler in the surviving source — see the note below the screens.
FIG. 05 Directory services Five entries and Return. In the surviving source dserver() handles only Return; the matching operations exist as commands inside DOS.DEB, such as mkdir, deldir, cd and find.
FIG. 06 Other Softwares Mydos, a calculator, a calendar, a world timer and a game. Built by the same popupmenu() routine as every other menu, from a different table of strings.
The utilities
FIG. 07 Expression calculator Type an expression, get the answer; exit leaves. strchk() prepares the input and calcu() evaluates it. The checker recognises Sin, Cos, Tan, exp and log, and the source carries fact(), npr() and ncr() helpers.
FIG. 08 Calendar of 5000 years The month these screens were captured, October 2026. Arrow keys move by month and by year. The weekday comes from month, year and century code tables in CALENDAR.H.
FIG. 09 World timer Thirty-four cities, spelled as the author spelled them, handled as fifteen time-zone groups: Paris, Berlin, Hamberg, Frankfurt, Barcelona and Amsterdam share one branch. Type a lower-case name, enter the time in IST, and the program applies that group’s offset. Code in WLDTIMER.H.
FIG. 10 Shuffle A 4×4 sliding-tile puzzle: fifteen tiles numbered 10 to 24, a move counter and the message “Use Your Mind”. The program notes you can play once per run: “To play again exit from this software and then open it and play again.”
DOS.DEB, the shell inside
FIG. 11 Boot banner The Mydos entry opens DOS.DEB, a command shell written inside the same program: dos(), lines 1216–2100 of DBMPS.c, about two-fifths of the file. The banner is dated 25 February 2003, about nine months before the help screen’s 23 November.
FIG. 12 Two modes Insert mode writes text files — Shift+N starts a new one — and Shift+E leaves it for command mode.
FIG. 13 Command mode Leaving insert mode lands at a command: prompt. The shell’s own index command lists its commands — about forty, from attrib, cngattrib and freespace to piano, which plays notes on the PC speaker as keys are pressed.
What the surviving source does and does not contain

File services lists ten entries. Copy, Delete and Rename are wired to filecopy(), del() and ren(); the six after them — get and set file attributes, decrypt, compress, decompress and type — have no handler in this source, and neither does anything in the Directory services menu. Attribute changes, directory creation and removal, and file search exist instead as commands inside DOS.DEB. Compress, decompress and decrypt appear only as menu text and status-bar messages.

Source code

All five files, unmodified. Pick a file on the left and it opens on the right. WLDTIMER.H and DOSFUNC.H are identical to copies listed elsewhere in this archive, and DBMPS.c is identical to MENUDOS.TXT in the Programs list.

DBMPS · 5 files
SOURCE CODE · UNMODIFIED
DBMPS.c
Download DBMPS.c
Loading…
Project 02 · Screens and a video · Graphics and text mode · Turbo C / C++ · MS-DOS

Programs in Action

Screens and a demo video from the DOS programs in this archive

Most of the programs in this archive were never shown running. These captures add screens and a short video of some of them, so the code can be read next to what it did.

The earlier captures (the desktop, the button window, My Computer and the paint program) are bitmap files dated 9 and 10 January 2005. The other screens and the video were recorded on 8 October 2026.

Where the matching source is in the archive, the caption links to it and the viewer below opens it. Where it is not here yet, the caption says so.

VIDEO BUILDWINDOWS A 56-second capture of the desktop being built, recorded 8 October 2026. It starts at a DOS prompt, introduces the taskbar, the volume icon and the separators one at a time (each with a short message and a key press), opens the Start menu, and ends with “Windows by Debasis Bhattacharjee. I try to developed it again. Thank you.” Matching text in: WINDOWS.H, MYWIN.H
10
Screens
1
Video, 0:56
8
Linked source files
2,593
Lines in those files

The screens

Desktop and windows
FIG. 14 My Windows 2004 A Windows-style desktop for DOS: a Start menu (Media Player, Notepad, Wordpad, Explorer, Scandisk, Iexplorer, MS Paint, Shutdown) and a taskbar with a clock. Capture dated 9 January 2005. Matching text in: WINDOWS.H, MYWIN.H
FIG. 15 Button window A WELCOME window with help and close buttons and a Click Me button, drawn in graphics mode. Capture dated 9 January 2005. Matching text in: BUTTON.TXT
FIG. 16 My Computer A My Computer window listing five drives with name, type, total size, used space and free space, and a No object selected status line. Capture dated 10 January 2005. Matching source (EXPLORER.C, MYCOMPUT.C) exists but is not in this archive yet.
Paint and colour
FIG. 17 My Paint A mouse-driven paint program whose title bar reads Developed By Debasis Bhattacharjee, with a toolbar (Table, Rec, Cir, Ers, Line, Fill, Text, Col, Ext, Con, Bnd, Pen, Save), hatched shapes, text in a decorative font and a help line at the bottom. Capture dated 9 January 2005. Matching text in: DEBPAINT.c
FIG. 18 Colour selection The COLOR SELECTION MENU: foreground and background colour rows, a blink option, and OK and CANCEL, with Tab or mouse selection. Captured 8 October 2026. Matching text in: COLOR.H, SelectColor.c
FIG. 19 Coloured calendar A monthly calendar for August 2026, typed in at the prompt, with Sundays in red. Captured 8 October 2026. Matching text in: COLCAL.TXT
Fractals and music
FIG. 20 Fern A green fern built up point by point on a black screen, in the shape of the Barnsley fern fractal. Captured 8 October 2026. No matching source has been identified yet.
FIG. 21 Fractal viewing area A purple viewing area in the middle of a black screen. Captured 8 October 2026. No matching source has been identified yet.
FIG. 22 Mandelbrot set The Mandelbrot set drawn in magenta tones inside the same viewing area. Captured 8 October 2026. No matching source has been identified yet.
FIG. 23 Virtual Piano VIRTUAL PIANO v1.0, with the splash text DEVLOPED BY DEBASIS BHATTACHARJEE, a range selector, a Quit button and an on-screen keyboard. Captured 8 October 2026. Matching text in: piano.cpp

Source code

The files that match the text on these screens. Four of them were already in the archive; SelectColor.c and piano.cpp were added with the October 2026 batch. Pick a file on the left and it opens on the right.

Programs in Action · 8 files
SOURCE CODE · UNMODIFIED
DEBPAINT.c
Download DEBPAINT.c
Loading…
Archive in progress

Individual programs built with this library — with their own full source, project structure and (where they survive) runtime screenshots — are being added to this archive next. This section will be populated with real projects only; nothing is placed here until it exists.

§07 · The Original Environment

The Environment.

Programming
C / C++
Compiler
Turbo C / Turbo C++
Era
~2002–2004
Environment
DOS
Graphics driver
EGAVGA.BGI (Borland EGA/VGA driver, present in the original archive)
Architecture
16-bit / compiler-specific

Can These Programs Run Today?

The original programs were designed for an older DOS/Turbo C environment and may not run directly on modern 64-bit Windows systems. They are not natively compatible with the modern Windows environment and may require an emulator, virtual machine, DOS environment, or other compatibility solution to run again.

Can We Bring Them Back?

The archive may eventually be restored through DOS emulation, virtual machines, historical compiler environments, compatibility layers, or by recreating the original Turbo C development environment. Not every project may be successfully restored — but the source code that survives is preserved here regardless of whether it runs again.

§08 · Then vs Now

Programming Then vs Now.

The point here isn't that old programming was better. It's how dramatically the development experience has changed.

Programming Then
  • Turbo C / Turbo C++
  • DOS
  • Manual pixel-level graphics
  • Custom GUI headers, built from scratch
  • Low-level BIOS/interrupt APIs
  • Limited debugging
  • Manual UI components, hand-drawn
Programming Now
  • Modern IDEs
  • GUI frameworks
  • Cross-platform libraries
  • Visual designers
  • Package managers
  • AI-assisted coding
  • Cloud development & modern APIs
§09 · Why I Built This

Why I Built This.

I learned C and C++ the way most programmers of that era in India did — through Turbo C, with the compiler's own F1 help screens standing in for what Google and Stack Overflow would later become. Graphics programming came next, and it changed how I thought about code: a line of C could put an actual pixel on the screen. That was thrilling in a way console output never was.

The question that led to Graphical C++ was simple: DOS gave you almost nothing toward a graphical interface. Every button, every window, every mouse click had to be built by hand from BIOS interrupts and raw pixel calls. So I built the missing layer myself — two header files that turned those low-level primitives into something closer to Visual Basic's Form/Label/Button model, so a whole desktop-style program could be written in five or ten lines instead of hundreds.

The programs may no longer run as easily as they once did. The computers are gone, the operating systems have changed, and the tools I used belong to another era. But the code remains.

Learning through experimentation — not tutorials, not Stack Overflow, just the compiler's help file and a lot of trial and error — is what this archive is really about. Sometimes a few thousand lines of old C++ are enough to bring an entire period of a programmer's life back to memory.

§10 · Timeline

Timeline.

2002
C / C++ experimentation begins, working in Turbo C.
2003
Graphics programming, mouse support and the first custom headers take shape.
2004
Graphical C++ takes form — GCPPFUNC.H and GCPPMAIN.H combine into a reusable GUI-style library, used to build small desktop-like DOS applications.
Today
The source code is preserved and published here as a digital archive — unmodified, in full.
§11 · Other Early C/C++ Work

Other Early C/C++ Work.

Archive note

The programs in this section are standalone projects from the same DOS/Turbo C era — they are not built on the Graphical C++ library (GCPPFUNC.H / GCPPMAIN.H) shown above. Each has its own separate headers and structure. They are preserved here unmodified, alongside the main archive, because they come from the same period of learning and experimentation.

Library Headers

Twenty header files from the same archive — support libraries for mouse input, menus, windows, color pickers, calendars and more. Some were built entirely by the author; a few (noted where it applies) reuse or adapt other programmers’ code, as was common practice at the time. One file, DESKTOP.H, survives as an empty 0-byte file and is shown as such.

Programs

Archive note

Every file below is C or C++ source code, despite most carrying a .TXT extension — that is simply how the author originally saved them. Filenames and extensions are preserved exactly as found; nothing has been renamed.

Below the two groups above, this archive continues with a second, larger batch pulled from the author’s wider personal folder of DOS-era code: a substantial ray-tracing project the author wrote, more of the author’s own headers and small programs, and — kept honestly separate — a large body of third-party and library source (GIF-Lib, a JPEG codec, a 3D engine, and several other credited works) that the author collected and studied from at the time, but did not write. Every entry in the third-party group below is labeled with what its own comments say about its origin. A last group, “Origin Unclear”, holds files whose own comments name no author, or credit two different people; each entry says which, and nothing in that group is claimed as the author’s own or as someone else’s.

SOURCE CODE · UNMODIFIED
Loading…
Download
Loading…
Also on this page, shown in full above rather than in this list: GCPPFUNC.H and GCPPMAIN.H, the core Graphical C++ library.
§12 · The Knowledgebase, 2004–05

The Knowledgebase.

Besides the programs, I kept a small website of my own, a knowledgebase of what I had learned about C. It was called Debmedia Creation and, in its 2005 rebuild, C Power. It held a list of programs by topic, a reference page for each of my functions, worked examples, my header files, and the longer programs in full. It was never tidy. The pages sit in two folders, several exist twice, and many of their links point at files that were never saved with them. The files are dated January 2004 to February 2005.

Here they are gathered in one place, arranged by purpose and linked to the code they describe. Choose a page on the left; it opens on the right as it was written. Under each page are the source files it talks about, which open in the same code viewer as the rest of this archive. The function index further down maps every function name the author used to the page that documents it and the header that defines it.

“Create myself or collected from some books and internets… Almost 98% of them were modified.” — how the site itself describes its functions, on the My Functions page.
Loading…
Original file

DMC.AVI — the logo animation the 2005 site opened with (2.6 seconds, 128×117 pixels, uncompressed). It is shown here converted to MP4 and enlarged three times; nothing has been redrawn.

Function Index

Every function name the 2004 and 2005 pages list, with the page that documents it and the files in this archive that define it. A name with no page was listed in the site’s index but never given its own page. A name with no definition is not defined in any file I have.

FunctionDocumented onDefined in

What Was Changed, and What Was Not

Restoration note

The text and the pictures of each page are as saved. Only the plumbing was repaired so the pages can open in a modern browser: the character encoding was converted to UTF-8; links between pages were pointed at the copies shown here; links to programs (.exe), to files that were not saved with the pages, and to outside websites are switched off and marked with a dotted underline; and pictures that were never saved show as blanks. The pages run inside a sandbox that does not execute scripts, so two small animation scripts on the 2004 pages do nothing. Each page’s untouched original is available with the Original file button. The dates are the files’ own modified dates.

“The programs may no longer run as easily as they once did. The computers are gone, the operating systems have changed, and the tools I used belong to another era. But the code remains. And sometimes, a few thousand lines of old C++ are enough to bring an entire period of a programmer's life back to memory.”

Debasis Bhattacharjee · Graphical C++ Archive