Advertisement
BinYamin

my_mouse.cpp

Aug 31st, 2014
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.87 KB | None | 0 0
  1. /*
  2. Author: Shah Hassan
  3. Date: long/forgot/ten
  4.  
  5. Can be run in Turbo C only.
  6. It's basically a support file, which I include whenever I make programs which require cursor and mouse.
  7. */
  8.  
  9. #include<graphics.h>
  10. #include<stdlib.h>
  11. #include<dos.h>
  12.  
  13. class Mouse{
  14.     union REGS in,out;
  15. public:
  16.     Mouse();
  17.     int show();
  18.     void getpos(int&x, int&y, int& click);
  19.     int hide();
  20.     void setpos(int x, int y);
  21. } crsr;
  22.  
  23. Mouse::Mouse() {
  24.     show();
  25.     setpos(10,10);
  26. }
  27.  
  28. int Mouse::show(){
  29.     in.x.ax=1;
  30.     int86(51,&in,&out);
  31.     return 1;
  32. }
  33.  
  34. void Mouse::getpos(int &xpos,int &ypos,int &click){
  35. //click
  36.     in.x.ax=3;
  37.     int86(51,&in,&out);
  38.     click=out.x.bx;
  39.     xpos=out.x.cx;
  40.     ypos=out.x.dx;
  41. }
  42.  
  43. int Mouse::hide(){
  44.     in.x.ax=2;
  45.     int86(51,&in,&out);
  46.     return 1;
  47. }
  48.  
  49. void Mouse::setpos(int xpos,int ypos) {
  50.     in.x.ax=4;
  51.     in.x.cx=xpos;
  52.     in.x.dx=ypos;
  53.     int86(51,&in,&out);
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement