/* ProgressBar : This programm contains code for progressbar it work same as progressbar displayed in window's environment. (Progressbar for Graphics program) */
#include <graphics.h>
#include <stdio.h>
#include <dos.h>
#include <conio.h>
#define CNT_ROW 5 //Counter in ProgressBar's --> Col position#define CNT_COL 40 //Counter in ProgressBar's --> Row position#define PROGRESS_X1 200//ProgressBar's --> Starting position#define PROGRESS_X2 460//ProgressBar's --> Ending position#define PROGRESS_Y1 55 //ProgressBar's --> Starting Height#define PROGRESS_Y2 85 //ProgressBar's --> Ending Height#define delayTime 50 //Speed of ProgressBarint main(void)
{
/* request auto detection */int gdriver = DETECT, gmode, errorcode;
int i,j,cnt=0,clrflag=0;
/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, "c:\\tc\\bgi");
/*-------Introduction Line----------*/
setcolor(LIGHTGREEN);
settextstyle(TRIPLEX_FONT,HORIZ_DIR,5);
outtextxy(5,100,"Graphical ProgressBar");
setcolor(LIGHTCYAN);
settextstyle(SMALL_FONT,HORIZ_DIR,6);
outtextxy(5,180,"Programmed By : Talented programmer");
outtextxy(5,200,"Email : admin@syntaxexample.com");
outtextxy(5,220,"Website : www.syntax-example.com");
/*-------Introduction Line----------*/
setcolor(CYAN);
j=PROGRESS_X1;
cnt=5;
for(i=j;i<PROGRESS_X2;i++){
delay(delayTime);
gotoxy(CNT_COL,CNT_ROW);
printf("%d",cnt);
rectangle(j,PROGRESS_Y1,i,PROGRESS_Y2);
if(i==(j+10)){
j=j+13;
i=j;
if(clrflag==1){
clrflag=0;
setcolor(CYAN);
}
else{
clrflag=1;
setcolor(BLUE);
}
cnt=cnt+5;
}
}
setcolor(WHITE);
outtextxy(5,260,"Press Any Key to Return...");
/* clean up */
getch();
// closegraph();return 0;
}