Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
App to apply exams
Message
From
24/09/2010 05:50:33
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
 
To
21/09/2010 09:35:44
Emerson Reed
Folhamatic Tecnologia Em Sistemas
Americana - São Paulo, Brazil
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9
Miscellaneous
Thread ID:
01482141
Message ID:
01482535
Views:
105
>Hi!
>How can I do to restrict user access to another apps or SO while running my app?
>I need to do this because my app is used to apply exams.

I don't know of such a thing, but there are other things you can do - using bindevent() to system messages to your app's window. You can trap the moment your app loses focus, and then decide what to do - log the event, force focus back to your app, etc.

I had done some of this once - here's an attempt to prevent the content of the clipboard leaving the app:
***
***	dcappfocus.prg
***

* 	2006/09/16 10:11:05
* 	Visual FoxPro 09.00.0000.3504 for Windows

*** based on Doug Hennig's article
*** ----------------------------------
***

#include include\WinEvents.H


DEFINE CLASS frmwinevents AS form
	Height = 214
	Width = 494
	ShowWindow = 2
	Caption = "Windows Events Test"
	stevka=""
	noldproc = 0
	nshnotify = 0
	Name = "frmWinEvents"

	PROCEDURE Init
		* Declare the Windows API functions we'll use.
		declare integer GetWindowLong in Win32API ;
			integer hWnd, integer nIndex
		declare integer CallWindowProc in Win32API ;
			integer lpPrevWndFunc, integer hWnd, integer Msg, integer wParam, ;
			integer lParam

		* Get a handle for the VFP Windows event handler.
		This.nOldProc = GetWindowLong(_screen.hWnd, GWL_WNDPROC)


		* Bind to the Windows events we're interested in.
		bindevent(_vfp.hWnd, WM_ACTIVATE,      This, 'HandleEvents')

	ENDPROC

*******************************
	PROCEDURE Destroy
		* Unregister us from receiving shell events, unbind all events from our
		* window and _vfp, and redisplay VFP.

		with This
			unbindevents(_vfp.hWnd)
		endwith
	ENDPROC

*******************************
	PROCEDURE HandleWindowsMessage
		lparameters hWnd, ;
			Msg, ;
			wParam, ;
			lParam
		local lnResult
		lnResult = CallWindowProc(This.nOldProc, hWnd, Msg, wParam, lParam)
		return lnResult
	ENDPROC


*******************************
	PROCEDURE HandleEvents
		lparameters hWnd, ;
			Msg, ;
			wParam, ;
			lParam
		local lcCaption, ;
			lnParm, ;
			lcPath
		do case
				
		* Handle an activate or deactivate event.
			case Msg = WM_ACTIVATE
				do case

		* Handle a deactivate event.
					case wParam = WA_INACTIVE
						this.stevka=_cliptext
						_cliptext=""

		* Handle an activate event (task switch or clicking on the title bar).
					case wParam = WA_ACTIVE
						IF !EMPTY(_cliptext)
						ELSE
							_cliptext=this.stevka
						endif
		* Handle an activate event (clicking in the client area of the window).
					case wParam = WA_CLICKACTIVE
						IF !EMPTY(_cliptext)
						ELSE
							_cliptext=this.stevka
						endif
				endcase
		ENDCASE
		*-- this plays the role of dodefault():
		return This.HandleWindowsMessage(hWnd, Msg, wParam, lParam)
	ENDPROC

ENDDEFINE
*

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform