The following bit of code is an adaptation from a part of my program.
Ignore the fact that DP% is always set to -1, as this is a normal posibility of the removed code. When the window is clicked on the loop runs to the error message. When the window 'X' close button is clicked on the same thing happens. Why does the system not pass to the PROC_CLOSE routine and QUIT? The close action is happening during the second loop of PROCAction. Surely, PROC_CLOSE should be actioned before it exits this loop, and I can't see anything else that should cause the system to ignore it.
Code: Select all
ON CLOSE PROC_CLOSE : RETURN
DP% = -1
DIM Mouse{X%, Y%, B%}
REPEAT
IF DP% < 0 THEN
PROC_DP
ENDIF
UNTIL DP% > -1
END
DEF PROC_DP
LOCAL K%, C%
REPEAT
IF DP% = -1 THEN SYS "MessageBox", @hwnd%, "Cannot continue until DP is not -1.", "Error", 64
W% = FNAction(K%, C%)
DP% = -1
UNTIL K% = 27 OR DP% <> -1
ENDPROC
DEF FNAction(RETURN K%, RETURN C%)
LOCAL W%
C% = 0
REPEAT
K% = INKEY(1)
MOUSE Mouse.X%, Mouse.Y%, Mouse.B%
UNTIL K% = -1 AND Mouse.B% = 0
REPEAT
K% = INKEY(1)
MOUSE Mouse.X%, Mouse.Y%, Mouse.B%
SYS "GetForegroundWindow" TO W%
UNTIL K% <> -1 OR Mouse.B% <> 0
IF W% = @hwnd% THEN = TRUE ELSE = FALSE
DEF PROC_CLOSE
QUIT
ENDPROC