#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <dos.h>
union REGS i,o;
char *dbox,*yes_up,*no_up,*yes_down,*no_down,*icon;
void DrawDialogBox(void);
void DialogBox(void);
int initmouse(void);
void showmouseptr(void);
void hidemouseptr(void);
void getmousepos(int *button,int *x,int *y);
void main(void)
{
int gdriver=DETECT,gmode,errorcode;
initgraph(&gdriver, &gmode, "..//bgi");
errorcode=graphresult();
if(errorcode!=grOk)
{
printf("Graphics not initialized");
printf("Error Status : %s",grapherrormsg(errorcode));
getche();
exit(1);
}
if(!initmouse())
{
printf("Mouse driver can't be loaded");
getche();
exit(1);
}
DrawDialogBox();
showmouseptr();
setbkcolor(BROWN);
DialogBox();
}
void DrawDialogBox(void) // actual drawing of dialog box
{
int area;
int poly[10];
struct textsettingstype textinfo;
gettextsettings(&textinfo);
settextstyle(0,HORIZ_DIR,1);
setfillstyle(1,BLUE);
bar(200,160,400,235);
setcolor(7);
outtextxy(205,163,"Message"); //title bar
setfillstyle(1,7);
bar(200,175,400,250);
bar(388,162,398,172);
setcolor(WHITE);
line(388,162,398,162);
line(388,162,388,172);
setcolor(5);
line(388,172,398,172);
line(398,162,398,172);
setcolor(7);
setcolor(8);
outtextxy(390,164,"X"); //close button
outtextxy(260,190," Exit ?"); //message
setcolor(WHITE);
line(200,160,400,160);
line(200,160,200,250);
setcolor(8); //outside normal look
line(400,160,400,250);
line(200,250,400,250);
setfillstyle(1,BLUE);
outtextxy(243,223,"Yes"); //button text
outtextxy(337,223,"No");
setcolor(LIGHTBLUE);
setcolor(WHITE);
line(230,215,280,215);
line(230,215,230,238);
line(320,215,370,215);
line(320,215,320,238);
setcolor(8);
line(280,215,280,238);
line(230,238,280,238);
line(370,215,370,238);
line(320,238,370,238);
poly[0] = 100;
poly[1] = 100;
poly[2] = 90;
poly[3] = 122;
poly[4] = 110;
poly[5] = 122;
poly[6] = poly[0];
poly[7] = poly[1];
setcolor(YELLOW);
setfillstyle(1,7);
bar(89,99,111,123);
setfillstyle(1,YELLOW);
fillpoly(4, poly);
setcolor(8);
settextstyle(4,0,1);
outtextxy(98,100,"!");
setcolor(WHITE);
area=imagesize(89,99,111,123);
icon=malloc(area);
getimage(89,99,111,123,icon);
putimage(89,99,icon,XOR_PUT);
putimage(210,180,icon,COPY_PUT);
setfillstyle(1,BLUE);
settextstyle(0,HORIZ_DIR,1);
setcolor(WHITE);
area=imagesize(198,158,402,252);
dbox=malloc(area);
getimage(198,158,402,252,dbox);
putimage(198,158,dbox,XOR_PUT);
putimage(198,158,dbox,XOR_PUT);
area=imagesize(230,215,280,238);
yes_up=malloc(area);
getimage(230,215,280,238,yes_up);
putimage(230,215,yes_up,XOR_PUT);
putimage(230,215,yes_up,XOR_PUT);
area=imagesize(320,215,370,238);
no_up=malloc(area);
getimage(320,215,370,238,no_up);
putimage(320,215,no_up,XOR_PUT);
putimage(320,215,no_up,XOR_PUT);
setcolor(8);
line(230,215,280,215);
line(230,215,230,238);
line(320,215,370,215);
line(320,215,320,238);
setcolor(WHITE);
line(280,215,280,238);
line(230,238,280,238);
line(370,215,370,238);
line(320,238,370,238);
area=imagesize(230,215,280,238);
yes_down=malloc(area);
getimage(230,215,280,238,yes_down);
putimage(230,215,yes_down,XOR_PUT);
putimage(230,215,yes_down,XOR_PUT);
area=imagesize(320,215,370,238);
no_down=malloc(area);
getimage(320,215,370,238,no_down);
putimage(320,215,no_down,XOR_PUT);
putimage(320,215,no_down,XOR_PUT);
putimage(320,215,no_up,COPY_PUT);
putimage(230,215,yes_up,COPY_PUT);
settextstyle(textinfo.font,0,textinfo.charsize);
}
void DialogBox(void) //Event Handler for dialog box
{
int button,x,y,in1=0,in2=0;
struct textsettingstype textinfo;
cleardevice();
putimage(198,158,dbox,XOR_PUT);
showmouseptr();
gettextsettings(&textinfo);
settextstyle(0,HORIZ_DIR,1);
while(1)
{
getmousepos(&button,&x,&y);
if(x>=388&&x<=398&&y>=162&&y<=172)
{
if((button&1)==1)
{
while((button&1)==1)
getmousepos(&button,&x,&y);
hidemouseptr(); //close button click
cleardevice();
settextstyle(textinfo.font,0,textinfo.charsize);
hidemouseptr();
cleardevice();
showmouseptr();
DialogBox();
break;
}
}
getmousepos(&button,&x,&y);
if(x>=230&&x<=280&&y>=215&&y<=238)
{
if((button&1)==1)
{
while((button&1)==1)
{
getmousepos(&button,&x,&y);
if(x>=230&&x<=280&&y>=215&&y<=238)
{
if(in1==1) continue;
hidemouseptr();
putimage(230,215,yes_down,COPY_PUT);
showmouseptr();
in1=1;
} //yes button click
else
{
if(in1==0)
continue;
hidemouseptr();
putimage(230,215,yes_up,COPY_PUT);
showmouseptr();
in1=0;
}
}
if(x>=230&&x<=280&&y>=215&&y<=238)
{
closegraph();
restorecrtmode();
exit(0);
}
}
}
if(x>=320&&x<=370&&y>=215&&y<=238)
{
if((button&1)==1)
{
while((button&1)==1)
{
getmousepos(&button,&x,&y);
if(x>=320&&x<=370&&y>=215&&y<=238)
{
if(in2==1) continue;
hidemouseptr();
putimage(320,215,no_down,COPY_PUT);
showmouseptr();
in2=1;
}
else //no button click
{
if(in2==0)
continue;
hidemouseptr();
putimage(320,215,no_up,COPY_PUT);
showmouseptr();
in2=0;
}
}
getmousepos(&button,&x,&y);
if(x>=320&&x<=370&&y>=215&&y<=238)
{
hidemouseptr();
cleardevice();
settextstyle(textinfo.font,0,textinfo.charsize);
hidemouseptr();
cleardevice();
showmouseptr();
DialogBox();
}
}
}
}
}
// Mouse Functions
int initmouse(void)
{
i.x.ax=0;
int86(0x33,&i,&o);
return (o.x.ax);
}
void showmouseptr(void)
{
i.x.ax=1;
int86(0x33,&i,&o);
}
void hidemouseptr(void)
{
i.x.ax=2;
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;
}
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <dos.h>
union REGS i,o;
char *dbox,*yes_up,*no_up,*yes_down,*no_down,*icon;
void DrawDialogBox(void);
void DialogBox(void);
int initmouse(void);
void showmouseptr(void);
void hidemouseptr(void);
void getmousepos(int *button,int *x,int *y);
void main(void)
{
int gdriver=DETECT,gmode,errorcode;
initgraph(&gdriver, &gmode, "..//bgi");
errorcode=graphresult();
if(errorcode!=grOk)
{
printf("Graphics not initialized");
printf("Error Status : %s",grapherrormsg(errorcode));
getche();
exit(1);
}
if(!initmouse())
{
printf("Mouse driver can't be loaded");
getche();
exit(1);
}
DrawDialogBox();
showmouseptr();
setbkcolor(BROWN);
DialogBox();
}
void DrawDialogBox(void) // actual drawing of dialog box
{
int area;
int poly[10];
struct textsettingstype textinfo;
gettextsettings(&textinfo);
settextstyle(0,HORIZ_DIR,1);
setfillstyle(1,BLUE);
bar(200,160,400,235);
setcolor(7);
outtextxy(205,163,"Message"); //title bar
setfillstyle(1,7);
bar(200,175,400,250);
bar(388,162,398,172);
setcolor(WHITE);
line(388,162,398,162);
line(388,162,388,172);
setcolor(5);
line(388,172,398,172);
line(398,162,398,172);
setcolor(7);
setcolor(8);
outtextxy(390,164,"X"); //close button
outtextxy(260,190," Exit ?"); //message
setcolor(WHITE);
line(200,160,400,160);
line(200,160,200,250);
setcolor(8); //outside normal look
line(400,160,400,250);
line(200,250,400,250);
setfillstyle(1,BLUE);
outtextxy(243,223,"Yes"); //button text
outtextxy(337,223,"No");
setcolor(LIGHTBLUE);
setcolor(WHITE);
line(230,215,280,215);
line(230,215,230,238);
line(320,215,370,215);
line(320,215,320,238);
setcolor(8);
line(280,215,280,238);
line(230,238,280,238);
line(370,215,370,238);
line(320,238,370,238);
poly[0] = 100;
poly[1] = 100;
poly[2] = 90;
poly[3] = 122;
poly[4] = 110;
poly[5] = 122;
poly[6] = poly[0];
poly[7] = poly[1];
setcolor(YELLOW);
setfillstyle(1,7);
bar(89,99,111,123);
setfillstyle(1,YELLOW);
fillpoly(4, poly);
setcolor(8);
settextstyle(4,0,1);
outtextxy(98,100,"!");
setcolor(WHITE);
area=imagesize(89,99,111,123);
icon=malloc(area);
getimage(89,99,111,123,icon);
putimage(89,99,icon,XOR_PUT);
putimage(210,180,icon,COPY_PUT);
setfillstyle(1,BLUE);
settextstyle(0,HORIZ_DIR,1);
setcolor(WHITE);
area=imagesize(198,158,402,252);
dbox=malloc(area);
getimage(198,158,402,252,dbox);
putimage(198,158,dbox,XOR_PUT);
putimage(198,158,dbox,XOR_PUT);
area=imagesize(230,215,280,238);
yes_up=malloc(area);
getimage(230,215,280,238,yes_up);
putimage(230,215,yes_up,XOR_PUT);
putimage(230,215,yes_up,XOR_PUT);
area=imagesize(320,215,370,238);
no_up=malloc(area);
getimage(320,215,370,238,no_up);
putimage(320,215,no_up,XOR_PUT);
putimage(320,215,no_up,XOR_PUT);
setcolor(8);
line(230,215,280,215);
line(230,215,230,238);
line(320,215,370,215);
line(320,215,320,238);
setcolor(WHITE);
line(280,215,280,238);
line(230,238,280,238);
line(370,215,370,238);
line(320,238,370,238);
area=imagesize(230,215,280,238);
yes_down=malloc(area);
getimage(230,215,280,238,yes_down);
putimage(230,215,yes_down,XOR_PUT);
putimage(230,215,yes_down,XOR_PUT);
area=imagesize(320,215,370,238);
no_down=malloc(area);
getimage(320,215,370,238,no_down);
putimage(320,215,no_down,XOR_PUT);
putimage(320,215,no_down,XOR_PUT);
putimage(320,215,no_up,COPY_PUT);
putimage(230,215,yes_up,COPY_PUT);
settextstyle(textinfo.font,0,textinfo.charsize);
}
void DialogBox(void) //Event Handler for dialog box
{
int button,x,y,in1=0,in2=0;
struct textsettingstype textinfo;
cleardevice();
putimage(198,158,dbox,XOR_PUT);
showmouseptr();
gettextsettings(&textinfo);
settextstyle(0,HORIZ_DIR,1);
while(1)
{
getmousepos(&button,&x,&y);
if(x>=388&&x<=398&&y>=162&&y<=172)
{
if((button&1)==1)
{
while((button&1)==1)
getmousepos(&button,&x,&y);
hidemouseptr(); //close button click
cleardevice();
settextstyle(textinfo.font,0,textinfo.charsize);
hidemouseptr();
cleardevice();
showmouseptr();
DialogBox();
break;
}
}
getmousepos(&button,&x,&y);
if(x>=230&&x<=280&&y>=215&&y<=238)
{
if((button&1)==1)
{
while((button&1)==1)
{
getmousepos(&button,&x,&y);
if(x>=230&&x<=280&&y>=215&&y<=238)
{
if(in1==1) continue;
hidemouseptr();
putimage(230,215,yes_down,COPY_PUT);
showmouseptr();
in1=1;
} //yes button click
else
{
if(in1==0)
continue;
hidemouseptr();
putimage(230,215,yes_up,COPY_PUT);
showmouseptr();
in1=0;
}
}
if(x>=230&&x<=280&&y>=215&&y<=238)
{
closegraph();
restorecrtmode();
exit(0);
}
}
}
if(x>=320&&x<=370&&y>=215&&y<=238)
{
if((button&1)==1)
{
while((button&1)==1)
{
getmousepos(&button,&x,&y);
if(x>=320&&x<=370&&y>=215&&y<=238)
{
if(in2==1) continue;
hidemouseptr();
putimage(320,215,no_down,COPY_PUT);
showmouseptr();
in2=1;
}
else //no button click
{
if(in2==0)
continue;
hidemouseptr();
putimage(320,215,no_up,COPY_PUT);
showmouseptr();
in2=0;
}
}
getmousepos(&button,&x,&y);
if(x>=320&&x<=370&&y>=215&&y<=238)
{
hidemouseptr();
cleardevice();
settextstyle(textinfo.font,0,textinfo.charsize);
hidemouseptr();
cleardevice();
showmouseptr();
DialogBox();
}
}
}
}
}
// Mouse Functions
int initmouse(void)
{
i.x.ax=0;
int86(0x33,&i,&o);
return (o.x.ax);
}
void showmouseptr(void)
{
i.x.ax=1;
int86(0x33,&i,&o);
}
void hidemouseptr(void)
{
i.x.ax=2;
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;
}