''
'' $Id: BlockInput.bas,v 1.2 1994/03/16 11:42:40 alex Rel $
''
'' How to block a window (when busy)
''
'' Derived from RKM example (c) Copyright 1992 Commodore-Amiga, Inc.
''

DEFINT A-Z

'REM $INCLUDE Exec.bh
'REM $INCLUDE DOS.bh
'REM $INCLUDE Intuition.bh
'REM $INCLUDE Utility.bc

DIM SHARED tl&(40)	' required by BusyPointer.bas

REM $INCLUDE BLib/BusyPointer.bas	' generic busy pointer

LIBRARY OPEN "exec.library", LIBRARY_MINIMUM&
LIBRARY OPEN "dos.library", LIBRARY_MINIMUM&
LIBRARY OPEN "intuition.library", LIBRARY_MINIMUM&

' beginBusy
'
' Clear the requester with InitRequester. This makes a requester of
' width = 0, height = 0, left = 0, top = 0; in fact, everything is zero.
' This requester will simply block input to the window until
' EndRequest is called.
'
' The pointer is set to the busy pointer
'
SUB beginBusy(BYVAL win&, BYVAL waitRequest&)
	STATIC junk&

	busyPointer win&
	InitRequester waitRequest&
	junk& = Request&(waitRequest&, win&)
END SUB

'
' endBusy()
'
' Routine to reset the pointer to the system default, and remove the
' requester installed with beginBusy().
'
SUB endBusy(BYVAL win&, BYVAL waitRequest&)
	normalPointer win&
	EndRequest waitRequest&, win&
END SUB


SUB main
	DIM myreq(Requester_sizeof \ 2)

	allocBusyPointer	' allocate busy pointer imagery

	' Using SADD(...) to set a window title is sailing close to the wind, if
	' the string were to move in memory, the window title would suddenly
	' get corrupted... we're being quick & dirty here
	
	SetWindowTitles WINDOW(7), SADD("Busy - Input Blocked" + CHR$(0)), NOT 0&
	beginBusy WINDOW(7), VARPTR(myreq(0))

	Delay 150			' pause for around 3 seconds

	endBusy WINDOW(7), VARPTR(myreq(0))
	SetWindowTitles WINDOW(7), SADD("Not Busy" + CHR$(0)), NOT 0&

	freeBusyPointer		' release the busy pointer
END SUB

main	' start the main program
END
