Computer Pranks, Tricks,Tips

Collection of the excellent Computer Pranks,Computer Tricks and articles.

Saturday, July 7, 2012

Mouse Programming In C: See that Arrow at Runtime..!!

>>Hello Friends...In this post you will get some basic idea about Mouse-Programming in "C"  Language.
>>The concept of Union in C is used here to address the Registers which shows the co-ordinate positions if screen.
  • For Detecting Mouse value of Register is 0,
  • For Showing the text, value is 1,
  • For Showing mouse graphics, value is 1 with getch().

#include <dos.h>
#include <graphics.h>
union REGS in, out;

void detectmouse ()                                                 
{
 in.x.ax = 0;
 int86 (0X33,&in,&out);
 if (out.x.ax == 0)
 printf ("\nMouse Fail To Initialize");
 else
 printf ("\nMouse Succesfully Initialize");
}

void showmousetext ()
{
 in.x.ax = 1;
 int86 (0X33,&in,&out);
}

void showmousegraphics ()
{
 int gdriver = DETECT, gmode, errorcode;
 initgraph(&gdriver, &gmode, "c:\\tc\\bgi");
 in.x.ax = 1;
 int86 (0X33,&in,&out);
 getch ();
 closegraph ();
}

int main ()

{
 detectmouse ();
 showmousegraphics ();
 getch ();
 return 0;
}
           

1 comment:

meet_me said...

Just include this header file..
#inclulde at top..!