int line()
{
int key,x1,x2,y1,y2;
setcolor(gcolor);
tellme("Select the start point of the line. ");
while ((GetMenu(&x1,&y1,&key))!=0)
if (key==2)
return(1);
putpixel(x1,y1,gcolor);
tellme("Select the start point of the line. ");
while ((GetMenu(&x2,&y2,&key))!=0)
if (key==2)
return(1);
moveto(x1,y1);
lineto(x2,y2);
return(0);
}
int ClrScr()
{
setcolor(0);
rectangle(/*GFILLINTERIOR.*/scrwin[0].x1,scrwin[0].y1,
scrwin[0].x2,scrwin[0].y2);
if (fGrid)
Grid();
setcolor(gcolor);
return(0);
}
#pragma check_stack (off)
int MouseInit(void)
{
unsigned char far *pMouseDriver;
pMouseDriver=(unsigned char far *)_dos_getvect(0x33);
if (pMouseDriver==0||*pMouseDriver==0xcf)
return(0);
else
return(1);
}
int MouseReset(int *iButtonNum)
{
union REGS Reg;
if (!MouseInit())
return(0);
Reg.x.ax=0;
int86(0x33,®,®);
*iButtonNum=Reg.x.bx;
return(Reg.x.ax ? 1:0);
}
int MouseShow(void)
{
union REGS Reg;
if (!MouseInit())
return(0);
Reg.x.ax=1;
int86(0x33,®,®);
return(1);
}
int MouseHide(void)
{
union REGS Reg;
if (!MouseInit())
return(0);
Reg.x.ax=2;
int86(0x33,®,®);
return(1);
}
int MouseGetButton(int *iButtonStatus,int *iPointCol,int *iPointRow)
{
union REGS Reg;
if (!MouseInit())
{
*iButtonStatus=0;
return(0);
}
Reg.x.ax=3;
int86(0x33,®,®);
*iButtonStatus=Reg.x.bx;
*iPointCol=Reg.x.cx;
*iPointRow=Reg.x.dx;
return(1);
}
int MouseWaitRelease()
{
int button,x,y;
if (!MouseInit())
return(0);
button=1;
while (button)
MouseGetButton(&button,&x,&y);
return(1);
}
int MouseWaitRelease();
int MouseGetButton(int *,int *,int *);
int MouseHide(void);
int inside(int,int,int,int,int,int);
int GetMouse(int *,int *);
int MouseShow(void);
int ClrScr();
int GetMenu(int *x1,int *y1,int *key);
int MouseReset(int *ButtonNum);
int MouseInit(void);
void Process(void);
void ShowMenu();
void Grid(void);
int line();
void WrHint(char *);
void tellme(char *);
void gtext(int,int,char *,int);
void DrawFram(int,int,int,int,int);
char *HintStr[MENUNUM]={
"In drawing area. ",
"In hint area. ",
"In message area. ",
"In menu area. ",
"Set system color. There are 15 Kinds of color. ",
"Empty area. ",
"Empty area. ",
"Empty area. ",
"Grid on/off: Binding the selected point to the nearest cross. ",
"Line function:Select two points and draw a line between them. ",
"Empty menu. ",
"Empty menu. ",
"Empty menu. ",
"Empty menu. ",
"Empty menu. ",
"Empty menu. ",
"Empty menu. ",
"Empty menu. ",
"Empty menu. ",
"Empty menu. ",
"Empty menu. ",
"Empty menu. ",
"Empty menu. ",
"Empty menu. ",
"Empty menu. ",
"Empty menu. ",
"Empty menu. ",
"Clear current drawing area. ",
"Exit to DOS. "};
int gcolor=15,fGrid=0;
void main()
{ int GraphDriver=DETECT,GraphMode;
initgraph(&GraphDriver,&GraphMode,0);
int VRES16COLOR,DEFAULTMODE;
int iButton;
setgraphmode(VRES16COLOR);
// registerfonts("H:\\c7\\lib\\*.fon");
ShowMenu();
if (!MouseInit()){
WrHint (" Warning! No mouse device was detected! ");
getch();
setgraphmode(DEFAULTMODE);
exit(1);
}
else
if (!MouseReset(&iButton)){
WrHint(" Warning! The mouse has some problem! ");
getch();
setgraphmode(DEFAULTMODE);
exit(2);
}
Process();
}