当前位置: 技术问答>linux和unix
请问:如何在DOS下用C或汇编定义鼠标的形状?
来源: 互联网 发布时间:2014-11-04
本文导语: | #define CURSOR_ARROW 0 #define CURSOR_TEXT 1 #define CURSOR_CROSS 2 #define CURSOR_WAIT 3 #define CURSOR_SIZENWSE 4 #define CURSOR_SIZENS 5 #define CURSOR_SIZENESW 6 #define CURSOR_SIZEWE 7 #define CURSOR_HAND 8 #define CURSOR_FIRST CURSOR_A...
|
#define CURSOR_ARROW 0
#define CURSOR_TEXT 1
#define CURSOR_CROSS 2
#define CURSOR_WAIT 3
#define CURSOR_SIZENWSE 4
#define CURSOR_SIZENS 5
#define CURSOR_SIZENESW 6
#define CURSOR_SIZEWE 7
#define CURSOR_HAND 8
#define CURSOR_FIRST CURSOR_ARROW
#define CURSOR_LAST CURSOR_HAND
int SetCursor(int shape),GetCursor(); //return last shape
//--------------------------------------------------------------------
int SetCursor(int shape)
{
union REGS r; struct SREGS sr;
static POINT HotSpot[CURSOR_LAST+1]={POINT(0,0),POINT(7,8),POINT(7,7),
POINT(8,8),POINT(8,8),POINT(8,8),POINT(8,8),POINT(8,8),POINT(6,0)};
static WORD Shape[CURSOR_LAST+1][32] = { //AND, XOR
{ // arrow
0x3fff,0x1fff,0x0fff,0x07ff, 0x03ff,0x01ff,0x00ff,0x007f,
0x003f,0x001f,0x01ff,0x10ff, 0x30ff,0xf87f,0xf87f,0xfc7f,
0x0000,0x4000,0x6000,0x7000, 0x7800,0x7c00,0x7e00,0x7f00,
0x7f80,0x7c00,0x6c00,0x4600, 0x0600,0x0300,0x0300,0x0000
},{ // text (ibeam)
0xffff,0xffff,0xffff,0xffff, 0xffff,0xffff,0xffff,0xffff,
0xffff,0xffff,0xffff,0xffff, 0xffff,0xffff,0xffff,0xffff,
0x0770,0x0080,0x0080,0x0080, 0x0080,0x0080,0x0080,0x0080,
0x0080,0x0080,0x0080,0x0080, 0x0080,0x0080,0x0080,0x0770
},{ // cross
0xffff,0xffff,0xffff,0xffff, 0xffff,0xffff,0xffff,0xffff,
0xffff,0xffff,0xffff,0xffff, 0xffff,0xffff,0xffff,0xffff,
0x0080,0x0080,0x0080,0x0080, 0x0080,0x0080,0x0080,0xffff,
0x0080,0x0080,0x0080,0x0080, 0x0080,0x0080,0x0080,0x0080
},{ // wait
0xe007,0xe007,0xe007,0xf00f, 0xf00f,0xf00f,0xf81f,0xfc3f,
0xfc3f,0xf81f,0xf00f,0xf00f, 0xf00f,0xe007,0xe007,0xe007,
0x0000,0x07e0,0x0000,0x07e0, 0x07e0,0x0340,0x0080,0x0100,
0x0080,0x0100,0x02c0,0x0560, 0x02a0,0x0000,0x07e0,0x0000
},{ //size north west to south east
0xffff,0x807f,0x80ff,0x81ff, 0x83ff,0x81ff,0x88ff,0x9c7d,
0xbe39,0xff11,0xff81,0xffc1, 0xff81,0xff01,0xfe01,0xffff,
0x0000,0x7f80,0x4100,0x4200, 0x4400,0x4a00,0x5500,0x6282,
0x4146,0x00aa,0x0052,0x0022, 0x0042,0x0082,0x01fe,0x0000
},{ // size north to south
0xfeff,0xfc7f,0xf83f,0xf01f, 0xe00f,0xfc7f,0xfc7f,0xfc7f,
0xfc7f,0xfc7f,0xfc7f,0xe00f, 0xf01f,0xf83f,0xfc7f,0xfeff,
0x0100,0x0280,0x0440,0x0820, 0x1ef0,0x0280,0x0280,0x0280,
0x0280,0x0280,0x0280,0x1ef0, 0x0820,0x0440,0x0280,0x0100
},{ // size north east to south west
0xffff,0xfe01,0xff01,0xff81, 0xffc1,0xff81,0xff11,0xbe39,
0x9c7d,0x88ff,0x81ff,0x83ff, 0x81ff,0x80ff,0x807f,0xffff,
0x0000,0x01fe,0x0082,0x0042, 0x0022,0x0052,0x00aa,0x4146,
0x6282,0x5500,0x4a00,0x4400, 0x4200,0x4100,0x7f80,0x0000
},{ // size west to east
0xffff,0xffff,0xffff,0xf7ef, 0xe7e7,0xc7e3,0x8001,0x0000,
0x8001,0xc7e3,0xe7e7,0xf7ef, 0xffff,0xffff,0xffff,0xffff,
0x0000,0x0000,0x0000,0x0810, 0x1818,0x2814,0x4ff2,0x8001,
0x4ff2,0x2814,0x1818,0x0810, 0x0000,0x0000,0x0000,0x0000
},{ // hand
0xfdff,0xf8ff,0xf8ff,0xf8ff, 0xf87f,0xf81f,0xf807,0x8803,
0x8003,0xc003,0xe003,0xe003, 0xf003,0xf807,0xfc07,0xf803,
0x0000,0x0200,0x0200,0x0200, 0x0200,0x0280,0x02a0,0x03e8,
0x33f8,0x1bf8,0x0bf8,0x0ff8, 0x07f8,0x03f0,0x01f0,0x0000
}
};
r.x.ax=0x0009;
r.x.bx=HotSpot[shape].x;
r.x.cx=HotSpot[shape].y;
r.x.dx=FP_OFF(Shape[shape]);
sr.es=FP_SEG(Shape[shape]);
int86x(0x33,&r,&r,&sr);
MouseOff(); MouseOn(); //redraw mouse cursor
int old=_CursorShape_; _CursorShape_ = shape;
return old;
}
#define CURSOR_TEXT 1
#define CURSOR_CROSS 2
#define CURSOR_WAIT 3
#define CURSOR_SIZENWSE 4
#define CURSOR_SIZENS 5
#define CURSOR_SIZENESW 6
#define CURSOR_SIZEWE 7
#define CURSOR_HAND 8
#define CURSOR_FIRST CURSOR_ARROW
#define CURSOR_LAST CURSOR_HAND
int SetCursor(int shape),GetCursor(); //return last shape
//--------------------------------------------------------------------
int SetCursor(int shape)
{
union REGS r; struct SREGS sr;
static POINT HotSpot[CURSOR_LAST+1]={POINT(0,0),POINT(7,8),POINT(7,7),
POINT(8,8),POINT(8,8),POINT(8,8),POINT(8,8),POINT(8,8),POINT(6,0)};
static WORD Shape[CURSOR_LAST+1][32] = { //AND, XOR
{ // arrow
0x3fff,0x1fff,0x0fff,0x07ff, 0x03ff,0x01ff,0x00ff,0x007f,
0x003f,0x001f,0x01ff,0x10ff, 0x30ff,0xf87f,0xf87f,0xfc7f,
0x0000,0x4000,0x6000,0x7000, 0x7800,0x7c00,0x7e00,0x7f00,
0x7f80,0x7c00,0x6c00,0x4600, 0x0600,0x0300,0x0300,0x0000
},{ // text (ibeam)
0xffff,0xffff,0xffff,0xffff, 0xffff,0xffff,0xffff,0xffff,
0xffff,0xffff,0xffff,0xffff, 0xffff,0xffff,0xffff,0xffff,
0x0770,0x0080,0x0080,0x0080, 0x0080,0x0080,0x0080,0x0080,
0x0080,0x0080,0x0080,0x0080, 0x0080,0x0080,0x0080,0x0770
},{ // cross
0xffff,0xffff,0xffff,0xffff, 0xffff,0xffff,0xffff,0xffff,
0xffff,0xffff,0xffff,0xffff, 0xffff,0xffff,0xffff,0xffff,
0x0080,0x0080,0x0080,0x0080, 0x0080,0x0080,0x0080,0xffff,
0x0080,0x0080,0x0080,0x0080, 0x0080,0x0080,0x0080,0x0080
},{ // wait
0xe007,0xe007,0xe007,0xf00f, 0xf00f,0xf00f,0xf81f,0xfc3f,
0xfc3f,0xf81f,0xf00f,0xf00f, 0xf00f,0xe007,0xe007,0xe007,
0x0000,0x07e0,0x0000,0x07e0, 0x07e0,0x0340,0x0080,0x0100,
0x0080,0x0100,0x02c0,0x0560, 0x02a0,0x0000,0x07e0,0x0000
},{ //size north west to south east
0xffff,0x807f,0x80ff,0x81ff, 0x83ff,0x81ff,0x88ff,0x9c7d,
0xbe39,0xff11,0xff81,0xffc1, 0xff81,0xff01,0xfe01,0xffff,
0x0000,0x7f80,0x4100,0x4200, 0x4400,0x4a00,0x5500,0x6282,
0x4146,0x00aa,0x0052,0x0022, 0x0042,0x0082,0x01fe,0x0000
},{ // size north to south
0xfeff,0xfc7f,0xf83f,0xf01f, 0xe00f,0xfc7f,0xfc7f,0xfc7f,
0xfc7f,0xfc7f,0xfc7f,0xe00f, 0xf01f,0xf83f,0xfc7f,0xfeff,
0x0100,0x0280,0x0440,0x0820, 0x1ef0,0x0280,0x0280,0x0280,
0x0280,0x0280,0x0280,0x1ef0, 0x0820,0x0440,0x0280,0x0100
},{ // size north east to south west
0xffff,0xfe01,0xff01,0xff81, 0xffc1,0xff81,0xff11,0xbe39,
0x9c7d,0x88ff,0x81ff,0x83ff, 0x81ff,0x80ff,0x807f,0xffff,
0x0000,0x01fe,0x0082,0x0042, 0x0022,0x0052,0x00aa,0x4146,
0x6282,0x5500,0x4a00,0x4400, 0x4200,0x4100,0x7f80,0x0000
},{ // size west to east
0xffff,0xffff,0xffff,0xf7ef, 0xe7e7,0xc7e3,0x8001,0x0000,
0x8001,0xc7e3,0xe7e7,0xf7ef, 0xffff,0xffff,0xffff,0xffff,
0x0000,0x0000,0x0000,0x0810, 0x1818,0x2814,0x4ff2,0x8001,
0x4ff2,0x2814,0x1818,0x0810, 0x0000,0x0000,0x0000,0x0000
},{ // hand
0xfdff,0xf8ff,0xf8ff,0xf8ff, 0xf87f,0xf81f,0xf807,0x8803,
0x8003,0xc003,0xe003,0xe003, 0xf003,0xf807,0xfc07,0xf803,
0x0000,0x0200,0x0200,0x0200, 0x0200,0x0280,0x02a0,0x03e8,
0x33f8,0x1bf8,0x0bf8,0x0ff8, 0x07f8,0x03f0,0x01f0,0x0000
}
};
r.x.ax=0x0009;
r.x.bx=HotSpot[shape].x;
r.x.cx=HotSpot[shape].y;
r.x.dx=FP_OFF(Shape[shape]);
sr.es=FP_SEG(Shape[shape]);
int86x(0x33,&r,&r,&sr);
MouseOff(); MouseOn(); //redraw mouse cursor
int old=_CursorShape_; _CursorShape_ = shape;
return old;
}