Pages

Mouse pointer with menu in c language.

Friday 12 July 2013


Note: This program is compiled and executed in Turbo 3.0

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


//mouse pointer functions
union REGS in,out;

       int callmouse()
       {
     in.x.ax=1;
     int86(51,&in,&out);
     return 1;
       }
       void mouseposi(int &xpos,int &ypos,int &click)
       {
     in.x.ax=3;
     int86(51,&in,&out);
     click=out.x.bx;
     xpos=out.x.cx;
     ypos=out.x.dx;
}
      void setposi(int &xpos,int &ypos)
      {
    in.x.ax=4;
    in.x.cx=xpos;
    in.x.dx=ypos;
    int86(51,&in,&out);
      }
//end mouse pointer code

int set_command()
{
    int x,y,cl,a,b, change, i;
    a=100;
    b=400;
    setposi(a,b);
    callmouse();
    gotoxy(10, 12);
    //printf("%d", cl);
    do
    {
   change=cl;
   mouseposi(x,y,cl);
   gotoxy(10, 7);
   printf("x=%d  y=%d   click=%d", x, y, cl);
   gotoxy(10,9);
   if(i==26)
   {
printf("Enter New Entry.");
   }
   if(cl!=change)
   {
if((x>=10 && x<=95) && (y>=6 && y<=18))
{
      printf("Goto Setter.     ");
}
if((x>=95 && x<=190) && (y>=6 && y<=18))
{
    printf("Edit Data.       ");
}
if((x>=350 && x<=480) && (y>=6 && y<=18))
{
     printf("Goto Main.       ");
}
if((x>=495 && x<=575) && (y>=6 && y<=18))
{
     printf("Save data in file");
}
if((x>=585 && x<=630) && (y>=6 && y<=18))
{
     return 0;
}
   }
    }while(!kbhit());
}

int main(void)
{
   char command;
   clrscr();
   int gdriver = DETECT, gmode, errorcode;
   clrscr();
   initgraph(&gdriver, &gmode, "C:\\turboc3\\bgi");
   setcolor(getmaxcolor());
   settextstyle(0,0,1);
   outtextxy(10,8,"New Entry | Edit Entry                     Goto: Main Menu | Save Data | Quit");

   set_command();
}

 

Search Box

Most Reading

Contact Form

Name

Email *

Message *