Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!oucsace!oucsace.cs.ohiou.edu From: tswingle@oucsace.cs.ohiou.edu (Tom Swingle) Newsgroups: comp.lang.pascal Subject: Microsoft mouse event handler Keywords: mouse Message-ID: <2929@oucsace.cs.OHIOU.EDU> Date: 14 Feb 91 03:40:18 GMT Sender: tswingle@oucsace.cs.OHIOU.EDU Organization: Ohio University CS Dept., Athens Lines: 50 I am trying to write a mouse event handler in Turbo Pascal using INT 33, function 12 (0Ch) which gets called whenever mouse buttons are pressed. The big thing I want to know is: Do you need to declare your event handler procedure as an interrupt? I have tried to do it both with and without declaring the procedure as an interrupt. Here is the program I was doing just to try it out: uses crt,dos,mouse; {Mouse unit contains most common mouse functions} var status,button,x,y:integer; regs:registers; {$F+} procedure leftbuttonpress; {interrupt?} begin writeln('Left button was pressed!'); end; {$F-} begin minit(status,button); {Reset mouse; declared in mouse unit} with regs do begin ax:=12; cx:=2; {Call when left button is pressed} es:=seg(leftbuttonpress); dx:=ofs(leftbuttonpress); end; intr($33,regs); repeat mread(button,x,y) until button and rightdown<>0; { This line just waits for the right mouse button to be pressed. Mread reads the current x and y position as well as the current button status. Rightdown is a constant equal to 2.} with regs do begin {Now turn off the event handling} ax:=12; cx:=0; end; intr($33,regs); end. When the procedure leftbuttonpress above is declared as an interrupt, the message is printed on the screen but then the program hangs, but as it is now I get a stack overflow error when it is called. The stack overflow error makes me think it was expecting an IRET when only a RETF was encountered, leaving the stack a mess. It seems to me like it should not be called as an interrupt, but rather just as a far call. Does anybody know which way is correct? And why won't either version of my program run? Did I mess something up in the above program? Thanks to anyone who can help me out.