You are here

C program to display mouse pointer in graphics mode

This program displays mouse pointer in graphics mode. First graphics mode is initialized and then mouse using initmouse.

C programming code

  1. #include<graphics.h>
  2. #include<conio.h>
  3. #include<dos.h>
  4.  
  5. int initmouse();
  6. void showmouseptr();
  7.  
  8. union REGS i, o;
  9.  
  10. main()
  11. {
  12.    int status, gd = DETECT, gm;
  13.  
  14.    initgraph(&gd,&gm,"C:\\TC\\BGI");
  15.  
  16.    status = initmouse();
  17.  
  18.    if ( status == 0 )
  19.       printf("Mouse support not available.\n");
  20.    else
  21.       showmouseptr();
  22.  
  23.    getch();
  24.    return 0;
  25. }
  26.  
  27. int initmouse()
  28. {
  29.    i.x.ax = 0;
  30.    int86(0X33, &i, &o);
  31.    return ( o.x.ax );
  32. }
  33.  
  34. void showmouseptr()
  35. {
  36.    i.x.ax = 1;
  37.    int86(0X33, &i, &o);
  38. }