Using the mouse in Turbo Pascal 7.0?

genie -  
 Titouan -
Hello everyone,
I want to know how to use the mouse in Turbo Pascal (for example, the user selects options by clicking on them)
I am not familiar with it at all, that's why I need your help
thank you in advance for your assistance :)
Configuration: Windows XP Firefox 2.0.0.14

5 answers

Titouan
 
To display the mouse on TP7 in a full-screen program, you need to use assembly language:

program souris;

uses crt;

begin
writeln('no mouse');
readln;
asm
mov ax, 1h; {set function 1h in ax}
int 33h; {interrupt that manages the mouse}
end;
writeln('with the mouse');
readln;
end.
1
watou Posted messages 241 Status Member 28
 
Hi kx !!

I want to know if you have tried to work with this because it hasn't worked for me !!

Thank you for responding!
--
The world will not be destroyed by those who do evil, but by those who look at them without doing anything.
0
KX Posted messages 19031 Status Moderator 3 020
 
No, I didn’t actually try to use it; I just debugged it so that it would compile, but I admit I'm unable to do better regarding a "mouse" unit...
--
Trust does not exclude control.
0
byakhlefncr Posted messages 260 Status Member 63
 
I'm sorry, I didn't notice the requests.

1. The unit used is Drivers and I have it in precompiled format (Drivers.tpu) and I forgot whether it was with Turbo Pascal or if I added it.

////////////////////////////////////////////////////////////////////////////////
For mouse usage in Pascal.

initevents; // initialize the mouse event handler.
doneevents; // Stop the event handler.
hidemouse; // hide the mouse pointer.
showmouse; // Show the mouse pointer.

getmouseevent(even); // to retrieve in 'even' of type 'TEvent' the mouse events.

if (even.buttons=mbleftbutton) then // Test the left click.

even.where.x; // Mouse cursor position on X
even.where.y; // Mouse cursor position on Y
//////////////////////////////////////////////////////////////////////////////////
2. I used these functions in programs and they worked wonderfully, but unfortunately with current operating systems the programs bug when using graphics functions.

3. These functions are included in the Turbo Pascal help.
0
byakhlefncr Posted messages 260 Status Member 63
 
Hello,

For using the mouse in Pascal.

initevents; // initialize the mouse event handler.
doneevents; // Stop the event handler.
hidemouse; // hide the mouse pointer.
showmouse; // Show the mouse pointer.

getmouseevent(even); // to retrieve mouse events in 'even' of type 'TEvent'.

if (even.buttons=mbleftbutton) then // Test the left click.

even.where.x; // Mouse cursor position on X
even.where.y; // Mouse cursor position on Y

Good luck.
-1
watou Posted messages 241 Status Member 28
 
Hello!
I want to know the name of the unit that contains these functions and procedures!
And does it work with Dev-Pascal?
And what is the TEvent type?
0
KX Posted messages 19031 Status Moderator 3 020 > watou Posted messages 241 Status Member
 
Dev-Pascal, Turbo-Pascal... it's the same language all this...

I couldn't find the name of the unit mentioned by byakhlefncr, however, depending on your needs, you can go shopping on the internet and find units created by other programmers (here for example), unfortunately, some of these are very old and are no longer compatible with the hardware we are currently using...

I hope to find something better soon...
--
Trust does not exclude control
0
KX Posted messages 19031 Status Moderator 3 020 > watou Posted messages 241 Status Member
 
Here is a unit I found on the internet (here), originally created for Turbo Pascal 5.5, which I adapted so that it compiles under Dev-Pascal 1.9.2 (I have not verified its proper functioning).
For the user manual of this unit, you will need to download the zip file provided by the programmer (in English).
unit mouse; interface uses dos; type array32word = array[0..31] of word; const hand : array32word =($ffff,$ffff,$ffff,$ffff,$ffff,$ffff,$ffff,$ffff, $ffff,$ffff,$ffff,$ffff,$ffff,$ffff,$ffff,$ffff, $0000,$0000,$0700,$0500,$0500,$05FC,$0554,$0D54, $1554,$1004,$0804,$0404,$0208,$0208,$0208,$0208); var mouse_clicked_x, mouse_clicked_y : word; function mouse_area(var xma):word; function mouse_clicked(button:word):boolean; function mousex:word; function mousey:word; function mousebutton:word; function mouse_swreset:boolean; procedure get_sensitivity(var x,y,speed:word); procedure set_sensitivity(x,y,speed:word); procedure physical_movement(var x,y:integer); procedure set_ratio(x,y:word); procedure cond_off(ux,uy,lx,ly:word); procedure set_speed2(threshold:word); procedure mouse_cursor(onoff:boolean); procedure mouse_position(var button_stat,x,y:word); procedure set_mouse_position(x,y:word); procedure set_mouse_x_bounds(xl,xu:word); procedure set_mouse_y_bounds(yl,yu:word); procedure set_mouse_cursor(x,y:word;var point:array32word); procedure set_text_cursor(aorh,startof,endof:word); function mouseparams(var num_buttons:word):boolean; function button_pressed(button:word;var count,x,y:word):boolean; function button_released(button:word;var count,x,y:word):boolean; implementation function mouse_area(var xma):word; var x:integer; mx,my,button : word; ma : array[1..100,1..4] of word absolute xma; begin x:=1; mouse_position(button,mx,my); while ma[x,1]<>0 do begin if (mx>=ma[x,1]) and (mx<=ma[x,2]) and (my>=ma[x,3]) and (my<=ma[x,4]) then begin mouse_area:=x; exit end; x:=x+1 end; mouse_area:=0 end; function mouse_swreset:boolean; var regs:registers; begin regs.ax:=$21; intr($33,regs); mouse_swreset:=regs.ax=$ffff end; procedure get_sensitivity(var x,y,speed:word); var regs:registers; begin regs.ax:=$1b; intr($33,regs); x:=regs.bx; y:=regs.cx; speed:=regs.dx end; procedure set_sensitivity(x,y,speed:word); var regs:registers; begin regs.ax:=$1a; regs.bx:=x; regs.cx:=y; regs.dx:=speed; intr($33,regs) end; procedure physical_movement(var x,y:integer); var regs:registers; begin regs.ax:=$b; intr($33,regs); x:=regs.cx; y:=regs.dx end; procedure set_ratio(x,y:word); var regs:registers; begin regs.ax:=$0f; x:=x and $7fff; y:=y and $7fff; regs.cx:=x; regs.dx:=y; intr($33,regs) end; procedure cond_off(ux,uy,lx,ly:word); var regs:registers; begin regs.ax:=$10; regs.cx:=ux; regs.dx:=uy; regs.si:=lx; regs.di:=ly; intr($33,regs) end; procedure set_speed2(threshold:word); var regs: registers; begin regs.ax:=$13; regs.dx:=threshold; intr($33,regs) end; function mouseparams(var num_buttons:word):boolean; var regs: registers; begin regs.ax:=$0; intr($33,regs); mouseparams:=regs.ax=$ffff; num_buttons:=regs.bx end; procedure mouse_cursor(onoff:boolean); var regs: registers; begin if onoff then regs.ax:=$1 else regs.ax:=$2; intr($33,regs) end; procedure mouse_position(var button_stat,x,y:word); var regs: registers; begin regs.ax:=$3; intr($33,regs); button_stat:=regs.bx; x:=regs.cx; y:=regs.dx end; function mousex:word; var b,x,y : word; begin mouse_position(b,x,y); mousex:=x end; function mousey:word; var b,x,y : word; begin mouse_position(b,x,y); mousey:=y end; function mousebutton:word; var b,x,y : word; begin mouse_position(b,x,y); mousebutton:=b end; procedure set_mouse_position(x,y:word); var regs: registers; begin regs.ax:=$4; regs.cx:=x; regs.dx:=y; intr($33,regs) end; procedure set_mouse_x_bounds(xl,xu:word); var regs: registers; begin regs.ax:=$7; regs.cx:=xl; regs.dx:=xu; intr($33,regs) end; procedure set_mouse_y_bounds(yl,yu:word); var regs: registers; begin regs.ax:=$8; regs.cx:=yl; regs.dx:=yu; intr($33,regs) end; function button_pressed(button:word;var count,x,y:word):boolean; var regs:registers; begin regs.ax:=$5; regs.bx:=button; intr($33,regs); count:=regs.bx; x:=regs.cx; y:=regs.dx; button_pressed:=(regs.ax=1) end; function mouse_clicked(button:word):boolean; var trash1 : boolean; count : word; begin trash1:=button_pressed(button,count,mouse_clicked_x,mouse_clicked_y); mouse_clicked:=count>0 end; function button_released(button:word;var count,x,y:word):boolean; var regs:registers; begin regs.ax:=$5; regs.bx:=button; intr($33,regs); count:=regs.bx; x:=regs.cx; y:=regs.dx; button_released:=(regs.ax=0) end; procedure set_mouse_cursor(x,y:word;var point:array32word ); var regs : registers; begin regs.ax:=$9; regs.bx:=x; regs.cx:=y; regs.es:=seg(point[0]); regs.dx:=ofs(point[0]); intr($33,regs) end; procedure set_text_cursor(aorh,startof,endof:word); var regs:registers; begin regs.ax:=$0a; regs.bx:=aorh; if aorh=0 then begin startof:=startof or $00ff; endof:=endof and $ff00 end; regs.cx:=startof; regs.dx:=endof; intr($33,regs) end; end.

--
Trust does not exclude control.
0