The program shows how you can use mouse in a
Graphic Windows and get the co-ordinates using int86 and int86x to execute an
8086 software interrupt specified by the argument.
#include <stdio.h>
#include <dos.h>
#include<stdlib.h>
union
REGS i,o;
int
button,x,y,gm,gd,mx,my;
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 ms()
{
i.x.ax=0;
int86(0x33,&i,&o);
while(!kbhit())
{
getmousepos(&button,&x,&y);
i.x.ax=1;
int86(0x33,&i,&o);
if(button==1)
{
gotoxy(x/8,y/10);
printf("X=%03d
y=%03d",x,y);
}
if(button==2)
{
exit(0);
}
}
}
void
main (void)
{
ms();
}
No comments:
Post a Comment