Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Prevent user interruption in Word
Message
From
12/02/2002 07:42:03
 
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00618735
Message ID:
00618757
Views:
11
This message has been marked as the solution to the initial question of the thread.
Caroline,

this seems to work
#define TRUE  .T.
#define FALSE .F.
#define	GW_HWNDNEXT		2
#define	GW_CHILD		5
*--------------------------------------------------------------------------
*--------------------------------------------------------------------------
procedure	do_it()
	
	declare integer EnableWindow in win32api integer, integer
	
	local obj, hwnd
	obj = createobject('Word.Application')
	obj.Visible = TRUE
	
	hwnd = GetSystemWindow(obj.Caption)
	
	
	** disable keyboard
	=EnableWindow(hwnd, 0)
	?? 'word keyboard disabled'
	
	suspend	&& the processing
	
	=EnableWindow(hwnd, 1)
	?? 'word keyboard enabled'

endproc
*---------------------------------------------------------------------------
function	GetSystemWindow(_Title)
	
	declare integer GetWindow in Win32API INTEGER, INTEGER
	declare integer GetDesktopWindow in Win32API
	declare integer GetWindowText in Win32API as _GetWindowText INTEGER, STRING @, INTEGER
										
	return	GetWindowHandle(_Title)
endfunc
*---------------------------------------------------------------------------
function	GetWindowHandle(_title, Handle, Children)
	local n, WindowText 
	
	Handle = GetWindow(iif(empty(Handle), GetDesktopWindow(), Handle), GW_CHILD)
	do while !empty(Handle)
		WindowText = GetWindowText(Handle)
		
		if( !empty(WindowText) )
			if( at(_title, WindowText) == 1 )
				return Handle
			endif
		endif
		if( Children )
			n = GetWindowHandle(_title, Handle, Children)
			if( !empty(n) )
				return n
			endif
		endif
		Handle = GetWindow(Handle, GW_HWNDNEXT)
	enddo
	return	0
endfunc
*---------------------------------------------------------------------------
>Does anybody know of a way to prevent the user from typing/clicking in Word while a complicated set of automation is happening. Preferably without having to make Word invisible.
>
>Thanks in anticipation.
Gregory
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform