Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Preventing user from changing applications

Status
Not open for further replies.

frothytoad

Technical User
Aug 1, 2003
32
US
I am working on an Access db project, and want to ensure that while the user is on a particular form s/he can't switch to or start another application (any app, even from the start menu).

Does anyone know if there is a way of doing this (an application-level LostFocus event, for example, or some other clever trick)?

Thanks...
 
I've never seen this done, and I highly doubt that it's possible. I think M$soft would consider that to be borderline hijacking. . .

I know that if I as a user was unable to access the Start menu, etc. I would suspect a system crash and probably restart my PC.

What about a simple message-box telling your users that changing apps mid-stream is a no-no, and bad things will certainly happen? [lol]



VBAjedi [swords]
 
I reckon you could do something but it would need API calls to find out where the mouse cursor was at any given time. Check that against the border positions for the app and you may have something that could work if you could find an API to move the mouse back inside the border again...would mean having continually running code tho...

Rgds, Geoff

Never test the depth of water with both feet

Help us to help you by reading FAQ222-2244 before you ask a question
 
Thanks to both. Telling the user not to change won't work in this case because they already know they shouldn't (they're students, and changing apps would be a type of cheating on a quiz).

Checking for mouse location might work, but then I need to make sure they can't change apps by the keyboard. Any thoughts on how to do this? When I trap for alt-tab or the Windows key, apparently the OS reacts to the keypress regardless of my changing it. (I tried a simple "KeyCode = 0" in each of the KeyDown, KeyUp, and KeyPress events.)

Thanks...

-- Jeff
 
Okay, that makes more sense now. I don't think this one will be easy. . .

If you could find the code (API or otherwise) that tells what window/app is active on the PC, you could just fire off a little sub that checks to see if your app is the active window, reactivates it if not, and uses Application.Ontime to call itself again in 5 seconds or so. You could also have it pop up a little message box warning them that if they did that again, they would receive a 0 on the quiz (a global variable could be used to keep track of the number of times your app wasn't the active window). Your students will never guess that they have a 5-second "window" during which they could technically cheat (not that 5 seconds will get them very far anyway).

Just brainstorming here. . .

VBAjedi [swords]
 
Yep. That sounds like the (maybe only) way to approach it. Now to find the right API call...

Thanks!

-- Jeff
 
try here:


the site isn't maintained anymore but there's a wealth of Api info still there

Rgds, Geoff

Never test the depth of water with both feet

Help us to help you by reading FAQ222-2244 before you ask a question
 
Yup - I know little about API calls but when I need to use one, that's where I go 1st

Rgds, Geoff

Never test the depth of water with both feet

Help us to help you by reading FAQ222-2244 before you ask a question
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top