Programming the mouse in Turbo C++

B

bintom

Hi,

I found a function "mousecall( )" on the web which draws a navigable
mouse on the screen. But I want the mouse to respond to clicks on
buttons that I have on the screen. How do I make the mouse read the co-
ordinates where it has been clicked? Thanks in anticipation.

Bintom


#include <graphics.h>
#include <dos.h>
#include <conio.h>

union REGS in, out;

void mousecall( )
{ in.x.ax = 1;
int86(51, &in, &out);
}

int main( )
{ int driver = DETECT, mode;
initgraph(&driver, &mode, "C:\\TC\\BGI");

mousecall();
settextstyle(2, 0, 5);

setfillstyle(1, 1);
bar3d(200, 200, 300, 240, 0, 0);
outtextxy(220, 210, "Button 1");

setfillstyle(1, 2);
bar3d(400, 200, 500, 240, 0, 0);
outtextxy(420, 210, "Button 2");

getch( );
closegraph( );
}
 
A

Alf P. Steinbach

* bintom:
Hi,

I found a function "mousecall( )" on the web which draws a navigable
mouse on the screen. But I want the mouse to respond to clicks on
buttons that I have on the screen. How do I make the mouse read the co-
ordinates where it has been clicked? Thanks in anticipation.

Bintom


#include <graphics.h>
#include <dos.h>
#include <conio.h>

union REGS in, out;

void mousecall( )
{ in.x.ax = 1;
int86(51, &in, &out);
}

int main( )
{ int driver = DETECT, mode;
initgraph(&driver, &mode, "C:\\TC\\BGI");

mousecall();
settextstyle(2, 0, 5);

setfillstyle(1, 1);
bar3d(200, 200, 300, 240, 0, 0);
outtextxy(220, 210, "Button 1");

setfillstyle(1, 2);
bar3d(400, 200, 500, 240, 0, 0);
outtextxy(420, 210, "Button 2");

getch( );
closegraph( );
}

You should simply forget the above code. It's for a long gone compiler (Turbo
C++) and a long gone environment (DOS). For help with GUI programming visit some
group with that topic, e.g. [comp.os.ms-windows.programmer.win32].


Cheers & hth.,

- Alf
 
R

Ron AF Greve

Hi,

Digged through some of my very old code. I believe at the time I used
turbo-C (but it must be from around 1995 or so, so not sure anymore). I am
not sure if you can still redirect interrupts and stuff like in the old days
on modern machines.

Hope it is of any use to you. But I would advice to look into windows
programming.


BOOL mousegetxy(unsigned char *left,

unsigned char *middle,

unsigned char *right,

unsigned int *x,

unsigned int *y

)

{

union REGS inregs, outregs;

struct SREGS segregs;

inregs.x.ax=0x3;

int86x(0x33, &inregs, &outregs, &segregs);

*left = outregs.x.bx & 1;

*right = outregs.x.bx & 2;

*middle = outregs.x.bx & 4;

*x = outregs.x.cx>>3;

*y = outregs.x.dx>>3;

return (*left|*middle|*right);

}

void mouseunhide(void)

{

union REGS inregs, outregs;

struct SREGS segregs;

inregs.x.ax=0x1;

int86x(0x33, &inregs, &outregs, &segregs);

}

void mousehide(void)

{

union REGS inregs, outregs;

struct SREGS segregs;

inregs.x.ax=0x2;

int86x(0x33, &inregs, &outregs, &segregs);

}







void mousesetsens( unsigned int x,

unsigned int y,

unsigned int speed

)

{

union REGS inregs, outregs;

struct SREGS segregs;

inregs.x.ax=0xF;

inregs.x.cx= x;

inregs.x.dx= y;





int86x(0x33, &inregs, &outregs, &segregs);

inregs.x.ax=0x13;

inregs.x.dx= speed;





int86x(0x33, &inregs, &outregs, &segregs);



}







void mousesetmaxxy( unsigned int minx,

unsigned int maxx,

unsigned int miny,

unsigned int maxy

)

{

union REGS inregs, outregs;

struct SREGS segregs;

inregs.x.ax=0x7;

inregs.x.cx= minx<<3;

inregs.x.dx= maxx<<3;





int86x(0x33, &inregs, &outregs, &segregs);

inregs.x.ax=0x8;

inregs.x.cx= miny<<3;

inregs.x.dx= maxy<<3;





int86x(0x33, &inregs, &outregs, &segregs);



}

BOOL mousehit(void)

{

union REGS inregs, outregs;

struct SREGS segregs;

inregs.x.ax=0x3;

int86x(0x33, &inregs, &outregs, &segregs);

return outregs.x.bx & 7;



}


Regards, Ron AF Greve

http://informationsuperhighway.eu
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top