Making Mouse Pointers

mycplus

mycplus

How to create the mouse pointers in c language. Different shapes can be given to the mouse pointer by changing the values of the cursor variable array.

#include <stdio.h>
#include <conio.h>
#include <dos.h>
#include <stdlib.h>
#include <graphics.h>

void showmouseptr();
int initmouse();
void changecursor(int *shape);
union REGS i,o;
struct SREGS s;

int cursor[32]={
 0x0000, 0x0000, 0x0000, 0x0000,
 0x8001, 0xc003, 0xf00f, 0xfc3f,
 0xfcff, 0xfcff, 0xfcff, 0xfcff,
 0x0000, 0x0000, 0x0000, 0x0000,
 0xffff, 0x8001, 0xffff, 0x8001,
 0x4002, 0x2004, 0x1008, 0x0240,
 0x0240, 0x0810, 0x2004, 0x4002,
 0x8001, 0xffff, 0x8001, 0xffff,
  };

void  main ()
{
     int gd=DETECT,gm;
     initgraph(&gd,&gm,"e:\\tc\\bgi");
     gotoxy(10,3);
     printf("HELLO");
     changecursor(cursor);
     showmouseptr();
     getch();
     }
    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  changecursor(int *shape)
    {
    i.x.ax=9;
    i.x.bx=0;
    i.x.cx=0;
    i.x.dx=(unsigned)shape;
    segread(&s);
    s.es=s.ds;
    int86(0x33,&i,&i);

 }
M. Saqib: Saqib is Master-level Senior Software Engineer with over 14 years of experience in designing and developing large-scale software and web applications. He has more than eight years experience of leading software development teams. Saqib provides consultancy to develop software systems and web services for Fortune 500 companies. He has hands-on experience in C/C++ Java, JavaScript, PHP and .NET Technologies. Saqib owns and write contents on mycplus.com since 2004.
Related Post