#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include<dos.h>
#include<math.h>
union REGS in,out;
void hide_mouse();
void show_mouse();
void detect_mouse();
void detect(int*,int*,int*);
void main(void)
{
int gdriver = DETECT, gmode, errorcode;
int xmax, ymax;
initgraph(&gdriver, &gmode, "");
errorcode = graphresult();
if (errorcode != grOk)
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1);
}
int x1,y1,button=1,t=0;
setcolor(getmaxcolor());
detect_mouse();
show_mouse();
// detect(&x1,&y1,&button);
while(!kbhit())
{
while(button==1)
{
detect(&x1,&y1,&button);
printf("%d %d",x1,y1);
putpixel(x1,y1,15);
}
}
getch();
}
void detect_mouse()
{
in.x.ax=0;
int86(0X33,&in,&out);
if(out.x.ax==0)
printf("not initialized!!");
else
printf("initialized!!");
}
void show_mouse()
{
in.x.ax=1;
int86(0X33,&in,&out);
getch();
}
void hide_mouse()
{
in.x.ax=2;
int86(0X33,&in,&out);
}
void detect(int*x,int*y,int *button)
{
in.x.ax=3;
int86(0X33,&in,&out);
*x=out.x.cx;
*y=out.x.dx;
*button=(out.x.bx)&1;
}
in this code, there is no compilation error.but when i click on the screen, it is not putting the pixel on it. BUT it is terminating properly. :'( have gave time to it but not getting what the problem is!! in this code, i am printing pixel at that co-ordinate on which i am clicking(MY AIM).