Skip to content

Latest commit

 

History

History
60 lines (41 loc) · 1.56 KB

sample_084.md

File metadata and controls

60 lines (41 loc) · 1.56 KB

Home

Locking mouse and keyboard input for the VFP application

Before you begin:

See also:


Code:

DECLARE INTEGER GetActiveWindow IN user32

DECLARE INTEGER EnableWindow IN user32;
 INTEGER hwnd,;
 INTEGER fEnable

* get handle of main VFP window
hwnd = GetActiveWindow()

? EnableWindow (hwnd, 0)
? "*** Input blocked - the main VFP window only"
	
FOR ii=1 TO 10
	DO proc1
ENDFOR

? EnableWindow (hwnd, 1)
? "*** Input unblocked"

PROCEDURE  proc1
	LOCAL ii
	WAIT WINDOW NOWAIT "Creating cursor..."
	CREATE CURSOR cs (id N(6), dt D)
	FOR ii=1 TO 10000
		INSERT INTO cs VALUES (ii, date()-ii)
	ENDFOR
	WAIT CLEAR
	? Chr(9) + "- cursor created at " + TTOC (datetime())
RETURN  

Listed functions:

EnableWindow
GetActiveWindow

Comment:

In this example user input is locked for VFP application only. This function works differently then the BlockInput does. The latter locks the window for all processes not just for the active process and thread.

With EnableWindow you can effectively lock a VFP application. But it is more like "you lock the door and throw away the key". To unlock it use the Task Manager, or beforehand submit the instructions to some other application along with the corresponding HWND.

Applied to windowed controls this function can enable or disable them.