📄 shubiao.c
字号:
/*
#ifndef MOUSEH
#define MOUSEH
const int RESET_MOUSE=0;
const int SHOW_MOUSE=1 ;
const int HIDE_MOUSE=2;
const int GET_MOUSE_STATUS=3;
const int SET_MOUSE_COORD=4;
const int CHECK_BUTTON_PRESS=5;
const int CHECK_BUTTON_PELEASE=6;
const int GET_MOUSE_MOVEMENT=11;
const int LEFT_BUTTON=0;
const int RIGHT_BUTTON=1;
const int EITHER_BUTTON=2;
class mouseobj
{
public:
int mouseexists;
virtual void mouseintr(int &m1,int &m2,int &m3,int &m4);
virtual int init(void);
virtual int reset(void);
virtual void hide(void);
virtual void show(void);
virtual void move(int x,int y);
virtual void getcoords(int &x,int &y);
virtual int buttonreleased(int whichbutton);
virtual int buttonpressed(int whichbutton);
int testbutton(int testtype,int whichbutton);
int inbox(int left,int top,int right,int bottom,int x,int y);
virtual int mouseobj::getinput(int whichbutton);
int mouseobj::waitforinput(int whichbutton);
};
*/
#include"time.h"
#include"alloc.h"
#include"math.h"
#include"dos.h"
#include"conio.h"
#include"bios.h"
typedef struct
{
int hor;
int ver;
int mak[2][16];
}mscurstype;
/* 箭头光标 */
mscurstype ArrowCursor=
{
0,0,
0x3fff,0x1fff,0x0fff,0x07ff,
0x03ff,0x01ff,0x00ff,0x007f,
0x003f,0x00ff,0x01ff,0x10ff,
0x30ff,0xf87f,0xf87f,0xfc3f,
0x0000,0x4000,0x6000,0x7000,
0x7800,0x7c00,0x7e00,0x7f00,
0x7f80,0x7e00,0x7c00,0x4600,
0x0600,0x0300,0x0300,0x0180
};
/* 手形光标 */
mscurstype HandCursor=
{
4,0,
0xf3ff,0xe1ff,0xe1ff,0xe1ff,
0xe001,0xe000,0xe000,0xe000,
0x8000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x8001,0xc003,
0xc000,0x1200,0x1200,0x1200,
0x13fe,0x1249,0x1249,0x1249,
0x7249,0x9001,0x9001,0x9001,
0x8001,0x8001,0x4002,0x3ffc
};
void SetCurShape(mscurstype mask)
{
union REGS r;
struct SREGS s;
r.x.ax=9;
r.x.bx=mask.hor;
r.x.cx=mask.ver;
r.x.dx=FP_OFF(&mask);
s.es=FP_SEG(&mask);
int86x(0x33,&r,&r,&s);
}
/* 鼠标初始化 */
int MouseReset(void)
{
union REGS ireg,oreg;
ireg.x.ax=0;
int86(0x33,&ireg,&oreg);
if (oreg.x.ax==0) return 0;
return 1;
}
/* 测鼠标键数 */
int ButtonNumber(void)
{
union REGS ireg,oreg;
ireg.x.ax=0;
int86(0x33,&ireg,&oreg);
if (oreg.x.bx==2) return 2;
if (oreg.x.bx==3) return 3;
return 0;
}
/* 显示鼠标 */
void ShowMouse(void)
{
union REGS ireg;
ireg.x.ax=1;
int86(0x33,&ireg,&ireg);
}
/* 隐藏鼠标 */
void HideMouse(void)
{
union REGS ireg;
ireg.x.ax=2;
int86(0x33,&ireg,&ireg);
}
/* 鼠标左键按下 */
int LeftPressed(void)
{
union REGS ireg,oreg;
ireg.x.ax=3;
int86(0x33,&ireg,&oreg);
return (oreg.x.bx&1);
}
/* 鼠标右键按下 */
int RightPressed(void)
{
union REGS ireg,oreg;
ireg.x.ax=3;
int86(0x33,&ireg,&oreg);
return (oreg.x.bx&2);
}
/* 获得鼠标坐标 */
/* x,y 均为象素坐标 */
/* 在文本方式下 tx=*x/8
ty=*y/8 */
void GetMousexy(int *x,int *y)
{
union REGS ireg;
ireg.x.ax=3;
int86(0x33,&ireg,&ireg);
*x=ireg.x.cx;
*y=ireg.x.dx;
}
/* 设置鼠标坐标 */
void SetMousexy(int x,int y)
{
union REGS ireg;
ireg.x.ax=4;
ireg.x.cx=x;
ireg.x.dx=y;
int86(0x33,&ireg,&ireg);
}
/* 设置鼠标水平移动范围 */
void SetXrange(int min,int max)
{
union REGS ireg;
ireg.x.ax=7;
ireg.x.cx=min;
ireg.x.dx=max;
int86(0x33,&ireg,&ireg);
}
/* 设置鼠标垂直移动范围 */
void SetYrange(int min,int max)
{
union REGS ireg;
ireg.x.ax=8;
ireg.x.cx=min;
ireg.x.dx=max;
int86(0x33,&ireg,&ireg);
}
/*读鼠标状态*/
void MouseRead(int *mousex, int *mousey, int *mousekey)
{
union REGS r1,r2;
struct SREGS s;
r1.x.ax=3;
int86x(0x33,&r1,&r2,&s);
*mousex=r2.x.cx;
*mousey=r2.x.dx;
*mousekey=r2.x.bx;
}
void setspeed(int mousex,int mousey)
{
union REGS r;
r.x.ax=15;
r.x.cx=mousex;
r.x.dx=mousey;
int86(0x33,&r,&r);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -