RESPUESTA A LA PREGUNTA NUMERO 47 a continuacion esta un programa de ejemplo para el uso del raton /* Programa : */ /* */ #include #include #include #include #include #include #include #include "raton.i" /*Incluye el objeto Raton*/ #define TRUE 1 #define FALSE 0 /* Define Funciones de Deteccion del Raton */ Restado Posicion; int TPos( int TP, int Abajo, int Arriba ) { return ( ( TP > Abajo ) && ( TP < Arriba ) ); } int main(void) { void mraton(void); /* inicializa el raton */ graton.Riniciar(); Posicion = graton.Rpulsado(BotonD); if (Posicion.contador_boton) DONE = TRUE; Posicion = graton.Rpulsado(BotonI); if (Posicion.contador_boton) { if ( TPos ( Posicion.ejey,5,20 )) { if ( TPos ( Posicion.ejex,10,40 )) { DONE = TRUE; } } if ( TPos ( Posicion.ejey,245,259 )) { if ( TPos ( Posicion.ejex,95,192 )) { hace lo que quieras si presionas el boton derecho el al area245,259,95,192 mraton(); } } } } void mraton(void) { Posicion = graton.Rpos(); int x= Posicion.ejex; int y= Posicion.ejey; graton.Rsitua(639,479); cleardevice(); graton.Rsitua(x,y); } a continuacion esta la subrutina del raton ( hay que guardarla en un archivo llamado raton.i raton.i #include #include #define menor (x, y) (x < y) ? x : y #define mayor (x, y) (x > y) ? x : y #define llamada_raton int86(0x33, &inreg, &outreg); #define BotonI 0 #define BotonD 1 #define BotonM 2 #define SOFTWARE 0 #define HARDWARE 1 #define FALSO 0 #define VERDAD 1 #define OFF 0 #define ON 1 union REGS inreg, outreg; typedef struct { int presente, botones; } Rresultado; typedef struct { int estado_boton, contador_boton, ejex, ejey; } Restado; typedef struct { int contador_x, contador_y; } Rmovimiento; typedef struct { unsigned flag, boton, ejex, ejey; } evento_raton; typedef struct { unsigned int MascaraPantalla[16], MascaraCursor[16], xcor, ycor; } g_cursor; static g_cursor FLECHA = { 0x1FFF, 0x0FFF, 0x07FF, 0x03FF, 0x01FF, 0x00FF, 0x007F, 0x003F, 0x001F, 0x003F, 0x01FF, 0x01FF, 0xE0FF, 0xF0FF, 0xF8FF, 0xF8FF, 0x0000, 0x4000, 0x6000, 0x7000, 0x7800, 0x7C00, 0x7E00, 0x7F00, 0x7F80, 0x7C00, 0x4C00, 0x0600, 0x0600, 0x0300, 0x0300, 0x0000, 1 ,1 }; static g_cursor MARCA = { 0xFFF0, 0xFFE0, 0xFFC0, 0xFF81, 0xFF03, 0x0607, 0x000F, 0x001F, 0x803F, 0xC07F, 0xE0FF, 0xF1FF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x0000, 0x0006, 0x000C, 0x0018, 0x0030, 0x0060, 0x70C0, 0x3980, 0x1F00, 0x0E00, 0x0400, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 5 ,10 }; static g_cursor CRUZ = { 0xF01F, 0xE000, 0xC007, 0x8003, 0x0441, 0x0C61, 0x0381, 0x0381, 0x0381, 0x0C61, 0x0441, 0x8003, 0xC007, 0xE00F, 0xF01F, 0xFFFF, 0x0000, 0x07C0, 0x0920, 0x1110, 0x2108, 0x4004, 0x4004, 0x783C, 0x4004, 0x4004, 0x2108, 0x1110, 0x0920, 0x07C0, 0x0000, 0x0000, 7 ,7 }; static g_cursor GUANTE = { 0xF3FF, 0xE1FF, 0xE1FF, 0xE1FF, 0xE1FF, 0xE049, 0xE000, 0x8000, 0x0000, 0x0000, 0x07FC, 0x07F8, 0x9FF9, 0x8FF1, 0xC003, 0xE007, 0x0C00, 0x1200, 0x1200, 0x1200, 0x1200, 0x13B6, 0x1249, 0x7249, 0x9249, 0x9001, 0x9001, 0x8001, 0x4002, 0x4002, 0x2004, 0x1FF8, 4 ,0 }; static g_cursor VIGA = { 0xF3FF, 0xE1FF, 0xE1FF, 0xE1FF, 0xE1FF, 0xE049, 0xE000, 0x8000, 0x0000, 0x0000, 0x07FC, 0x07F8, 0x9FF9, 0x8FF1, 0xC003, 0xE007, 0x0C30, 0x0240, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0180, 0x0240, 0x0C30, 7 ,7 }; class Raton { int Rvisible; protected: Raton(); ~Raton(); public: static evento_raton far *Reventos; Rmovimiento *Rcambio(); Rresultado *Riniciar(); Restado Rpos(); Restado Rpulsado( int boton ); Restado Rliberado( int boton ); void Rmuestra( int presente ); void Rsitua( int ejex, int ejey ); void Rlimitex( int min_x, int max_x ); void Rlimitey( int min_y, int max_y ); void Rrelacion_paso( int dimx, int dimy ); void Rvelocidad( int velocidad ); void Roculto( int izquierda, int arriba, int derecha, int abajo ); }; class GRaton : public Raton { private: void pon_cursor( int ejex, int ejey, unsigned Seg_mascara, unsigned Desp_mascara ); public: void Pon_Cursor( g_cursor EsteCursor ); void Rbrillante( int puesto ); }; class TRaton : public Raton { public: void Pon_Cursor( int tipo_cursor, unsigned s_inicio, unsigned s_fin ); void Rbrillante( int puesto ); }; Raton::Raton() { } Raton::~Raton() { } Rresultado *Raton::Riniciar() { static Rresultado m; Rvisible = OFF; inreg.x.ax = 0; llamada_raton; m.presente = outreg.x.ax; m.botones = outreg.x.bx; if ( m.presente ) Rmuestra( VERDAD ); return ( &m ); } void Raton::Rmuestra( int presente ) { if( presente ) { inreg.x.ax = 1; if ( !Rvisible ) llamada_raton; Rvisible = ON; } else { inreg.x.ax = 2; if( !Rvisible ) llamada_raton; Rvisible = OFF; } } Restado Raton::Rpos() { static Restado m; inreg.x.ax = 3; llamada_raton; m.estado_boton = outreg.x.bx; m.ejex = outreg.x.cx; m.ejey = outreg.x.dx; return (m); } void Raton::Rsitua( int ejex, int ejey ) { inreg.x.ax = 4; inreg.x.cx = ejex; inreg.x.dx = ejey; llamada_raton; } Restado Raton::Rpulsado(int boton) { static Restado m; inreg.x.ax = 5; inreg.x.bx = boton; llamada_raton; m.estado_boton = outreg.x.ax; m.contador_boton = outreg.x.bx; m.ejex = outreg.x.cx; m.ejey = outreg.x.dx; return (m); } Restado Raton::Rliberado( int boton ) { static Restado m; inreg.x.ax = 6; inreg.x.bx = boton; llamada_raton; m.estado_boton = outreg.x.ax; m.contador_boton = outreg.x.bx; m.ejex = outreg.x.cx; m.ejey = outreg.x.dx; return (m); } void Raton::Rlimitex( int min_x, int max_x ) { inreg.x.ax = 7; inreg.x.cx = min_x; inreg.x.dx = max_x; llamada_raton; } void Raton::Rlimitey( int min_y, int max_y ) { inreg.x.ax = 8; inreg.x.cx = min_y; inreg.x.dx = max_y; llamada_raton; } void GRaton::pon_cursor( int ejex, int ejey, unsigned Seg_mascara, unsigned Desp_mascara ) { struct SREGS seg; inreg.x.ax = 9; inreg.x.bx = ejex; inreg.x.cx = ejey; inreg.x.dx = Desp_mascara; seg.es = Seg_mascara; int86x( 0x33, &inreg, &outreg, &seg ); } void TRaton::Pon_Cursor( int tipo_cursor, unsigned s_inicio, unsigned s_fin ) { inreg.x.ax = 10; inreg.x.bx = tipo_cursor; inreg.x.cx = s_inicio; inreg.x.dx = s_fin; llamada_raton; } Rmovimiento* Raton::Rcambio() { static Rmovimiento m ; inreg.x.ax = 11; llamada_raton; m.contador_x = _CX; m.contador_y = _DX; return (&m); } void GRaton::Rbrillante( int puesto ) { if ( puesto ) inreg.x.ax = 13; else inreg.x.ax = 14; llamada_raton; } void Raton::Rrelacion_paso( int dimx, int dimy ) { inreg.x.ax = 15; inreg.x.cx = dimx; inreg.x.dx = dimy; llamada_raton; } void Raton::Roculto( int izquierda, int arriba, int derecha, int abajo ) { inreg.x.ax = 16; inreg.x.cx = izquierda; inreg.x.dx = arriba; inreg.x.si = derecha; inreg.x.di = abajo; llamada_raton; } void Raton::Rvelocidad( int velocidad ) { inreg.x.ax = 19; inreg.x.dx = velocidad; llamada_raton; } void GRaton::Pon_Cursor( g_cursor EsteCursor ) { pon_cursor( EsteCursor.xcor, EsteCursor.ycor, _DS, (unsigned) EsteCursor.MascaraPantalla ); } GRaton graton; TRaton traton; cualquier duda, consultame en mi direccion gm17@yahoo.com