Oh stuff! Yes, it solved the problem of keeping the location of the cursor, but for some reason it meant that clicking on any other icon stopped working (or rather, I would have to click 8-12 times before getting a response!) I've had to remove the !404=!400
However I shall have to try the other methods in Richard's article, as it would seem that interrupts are the problem.
GetCaretPos
-
- Posts: 78
- Joined: Sat 23 Jun 2018, 15:51
Re: GetCaretPos
If you put the !404=!400 on the next line after the ON SYS it should work from the start. The way you have it that statement does not get executed until the first interrupt.
I was thinking that the more complicated interrupt buffering might have been needed but if you have a solution now , great.
My version of the interrupt queuing is like this:
I just noticed that you have *SYS 1. That opens a floodgate of notifications that relate to mouse movement across controls and their repainting. I have recorded 15 to 20 interrupts in the queue just from a mouse movement across a dialog box in one of my programs, so I think you certainly need a large interrupt queue to flush those and filter the interrupts you want. Note the code above is different from the wiki in the way it handles the queue if it overflows. I did that because I had difficulty understanding why the wiki code worked, but of course it does!
Z
I was thinking that the more complicated interrupt buffering might have been needed but if you have a solution now , great.
My version of the interrupt queuing is like this:
Code: Select all
DIM Z@%(99) :REM Define 32 event buffer
ON SYS Z@%()=Z@%(0)+(3 AND Z@%(0)<99),@msg%,@wparam%,@lparam%,Z@%(1),Z@%(2),Z@%(3),Z@%(4),Z@%(5),Z@%(6),Z@%(7),Z@%(8),Z@%(9),Z@%(10),Z@%(11),Z@%(12),Z@%(13),Z@%(14),Z@%(15),Z@%(16),Z@%(17),Z@%(18),Z@%(19),Z@%(20),Z@%(21), \
\ Z@%(22),Z@%(23),Z@%(24),Z@%(25),Z@%(26),Z@%(27),Z@%(28),Z@%(29),Z@%(30),Z@%(31),Z@%(32),Z@%(33),Z@%(34),Z@%(35),Z@%(36),Z@%(37),Z@%(38),Z@%(39),Z@%(40),Z@%(41),Z@%(42),Z@%(43),Z@%(44),Z@%(45),Z@%(46), \
\ Z@%(47),Z@%(48),Z@%(49),Z@%(50),Z@%(51),Z@%(52),Z@%(53),Z@%(54),Z@%(55),Z@%(56),Z@%(57),Z@%(58),Z@%(59),Z@%(60),Z@%(61),Z@%(62),Z@%(63),Z@%(64),Z@%(65),Z@%(66),Z@%(67),Z@%(68),Z@%(69),Z@%(70),Z@%(71), \
\ Z@%(72),Z@%(73),Z@%(74),Z@%(75),Z@%(76),Z@%(77),Z@%(78),Z@%(79),Z@%(80),Z@%(81),Z@%(82),Z@%(83),Z@%(84),Z@%(85),Z@%(86),Z@%(87),Z@%(88),Z@%(89),Z@%(90),Z@%(91),Z@%(92),Z@%(93),Z@%(94),Z@%(95),Z@%(96): RETURN
!404=!400 :REM Divert ON MOUSE into ON SYS queue.
REM Main program idle loop
REPEAT
PROCDoEvents
UNTIL FALSE
END
DEF PROCDoEvents
LOCAL M%, W%, L%, E%()
DIM E%(2)
WHILE Z@%(0) :REM Z@%(0) is 0 if no event in the queue otherwise it points to the interrupt parameter list @msg%, @wparam% and @lparam%
E%()=Z@%(Z@%(0)-2),Z@%(Z@%(0)-1),Z@%(Z@%(0)) :REM get all data from queue in one statement to maintain synchronicity with no data loss.
Z@%(0) -= 3 :REM Adjust pointer to next interrupt in queue, if any
M%=E%(0):W%=E%(1):L%=E%(2) :REM Extract @msg%, wparam% and lparam%
CASE M% OF
WHEN 273: PRINT "End": END: REM action codes
WHEN 78:
WHEN 513: PRINT W%, L% AND &FFFF, L%>>>16
ENDCASE
ENDWHILE
WAIT 0
ENDPROC
I just noticed that you have *SYS 1. That opens a floodgate of notifications that relate to mouse movement across controls and their repainting. I have recorded 15 to 20 interrupts in the queue just from a mouse movement across a dialog box in one of my programs, so I think you certainly need a large interrupt queue to flush those and filter the interrupts you want. Note the code above is different from the wiki in the way it handles the queue if it overflows. I did that because I had difficulty understanding why the wiki code worked, but of course it does!
Z