c program to determine which mouse button is clicked - TopicsExpress



          

c program to determine which mouse button is clicked #include #include #include union REGS i, o; int initmouse() { i.x.ax = 0; int86(0X33,&i,&o); return ( o.x.ax ); } void showmouseptr() { i.x.ax = 1; 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; } main() { int gd = DETECT, gm, status, button, x, y; char array[50]; initgraph(&gd,&gm,"C:\TC\BGI"); settextstyle(DEFAULT_FONT,0,2); status = initmouse(); if ( status == 0 ) printf("Mouse support not available. "); else { showmouseptr(); getmousepos(&button,&x,&y); while(!kbhit()) { getmousepos(&button,&x,&y); if( button == 1 ) { button = -1; cleardevice(); sprintf(array,"Left Button clicked x = %d y = %d",x,y); outtext(array); } else if( button == 2 ) { button = -1; cleardevice(); sprintf(array,"Right Button clicked x = %d y = %d",x,y); outtext(array); } } } getch(); return 0; } by "jd" @Dangar Jaydev
Posted on: Sat, 28 Sep 2013 19:36:27 +0000

Trending Topics



Recently Viewed Topics




© 2015