Thread: need Help in Mouse Pointer

  1. #1
    Registered User
    Join Date
    Nov 2006
    Posts
    39

    need Help in Mouse Pointer

    Hi everybody,
    i wanna enable concole mouse point in BGI GRAPHIC , i need urs Help ,
    if u know how to Enable Mouse In C++ ( BGI GRAPHIC ) then reply me plz!

    i hv also a code of mouse pointer , BUT i can't understand This code ,
    No Error In Code.

    Code:
    #include<iostream.h>
    #include<conio.h>
    #include<process.h>
    #include<graphics.h>
    #include<dos.h>
    
    /*
    void showptr();
    void restrictptr(int,int,int,int);
    void getmpos(int*,int*,int*);
    int initmouse();
    void setmpos(int,int);
    void hideptr();
    */
    
    class mouse
    {
    private:
              union REGS i,o;
             struct SREGS s;
    
    public:
    
    /************* Initialize Mouse ********************/
    int initmouse()
      {
       i.x.ax=0;
       int86(0x33,&i,&o);
       return (o.x.ax);
      }
    
    /************* Display Pointer *********************/
    void showptr()
      {
       i.x.ax=1;
       int86(0x33,&i,&o);
      }
    
    /************* Restrict Mouse Movement *************/
    void restrictptr(int x1,int y1,int x2,int y2)
      {
       i.x.ax=7;
       i.x.cx=x1;
       i.x.dx=x2;
       int86(0x33,&i,&o);
    
       i.x.ax=8;
       i.x.cx=y1;
       i.x.dx=y2;
       int86(0x33,&i,&o);
      }
    
    /********** Get Mouse Position ***************/
    void getmpos(int *button,int *xx,int *yy)
      {
       i.x.ax=3;
       int86(0x33,&i,&o);
       *button=o.x.bx;
       *xx=o.x.cx;
       *yy=o.x.dx;
      }
    
    /********** Set Pointer Position **************/
    void setmpos(int xx,int yy)
     {
       i.x.ax=4;
       int86(0x33,&i,&o);
       xx=o.x.cx;
       yy=o.x.dx;
      }
    /***************HIDE MOUSE *********************/
    void hideptr()
    {
      i.x.ax=2;
      int86(0x33,&i,&o);
     } 
    
    };
    
    // end mouse class

  2. #2
    Hardware Engineer
    Join Date
    Sep 2001
    Posts
    1,398
    No Error In Code.
    Are you saying that you can compile it without errors?

    What exactly is the problem? Do you get an error when you run it? Does it ignore the mouse?

    I'm guessing, but I have a feeling this is not going to run on a modern 32-bit system. You probably have to run under 16-bit DOS...

    EDIT -
    If you need to use the mouse in a Windows Console application, check-out the MSDN Console Reference. The techniques & funcions described at MSDN should work with any modern Windows compiler/system.

    If you are a beginner, I strongly recommend that you learn ANSI/ISO Standard C++ first. (no mouse, graphics, color, or sound). Once you're comfortable with Standard C++, learn full-blown Windows programming, if you want/need to use a mouse.
    Last edited by DougDbug; 12-06-2006 at 05:39 PM.

  3. #3
    MFC killed my cat! manutd's Avatar
    Join Date
    Sep 2006
    Location
    Boston, Massachusetts
    Posts
    870
    For example, this:
    Code:
    #include<iostream.h>
    Hint: o-o-outdated, and not supported in even most modern compilers. It should be:
    Code:
    #include <iostream>
    Silence is better than unmeaning words.
    - Pythagoras
    My blog

  4. #4
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,688
    >#include<graphics.h>

    That is a 16bit dos library. As manutd said, learn thr basics before moving into advanced topics
    Double Helix STL

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. sorting the matrix question..
    By transgalactic2 in forum C Programming
    Replies: 47
    Last Post: 12-22-2008, 03:17 PM
  2. scope of a pointer?
    By Syneris in forum C++ Programming
    Replies: 6
    Last Post: 12-29-2005, 09:40 PM
  3. Question About Pointer To Pointer
    By BlitzPackage in forum C++ Programming
    Replies: 2
    Last Post: 09-19-2005, 10:19 PM
  4. Changing mouse pointer?
    By Matte in forum Windows Programming
    Replies: 9
    Last Post: 11-25-2004, 02:05 PM
  5. changing mouse pointer in c
    By MMM in forum Windows Programming
    Replies: 3
    Last Post: 05-11-2003, 08:28 PM