PDA

Click to See Complete Forum and Search --> : Trap keystrokes


chrisjk
Nov 28th, 1999, 08:29 AM
Hi everyone. How are we all today?

I have this form that I want the user to deal with before they can do anything with Windows (it traps the mouse to the form and I'm trying to get it to trap keyboard shortcuts). They have to supply a password to "unlock" the mouse/keyboard.

I'm using this code to stop them using keyboard shortcuts, it all works except the ALT+TAB one.

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)

ShiftDown = (Shift And vbShiftMask) > 0
CtrlDown = (Shift And vbCtrlMask) > 0
Altdown = (Shift And vbAltMask > 0)

If CtrlDown And KeyCode = vbKeyEscape Then
KeyCode = 0
ElseIf Altdown And KeyCode = vbKeyTab Then
KeyCode = 0
ElseIf Altdown And KeyCode = vbKeyF6 Then
KeyCode = 0
ElseIf Altdown And KeyCode = vbKeyF4 Then
KeyCode = 0
End If

End Sub

Can anyone spot anything wrong? I can't! Is Windows cheaky and not allow you to stop the use of ALT+TAB?

Whilst I'm here, are there any other keyboard shortcuts that I haven't coded for?

Many thanks to all (esp. those who assist :))

Regards,

------------------
- Chris
chris.kilhams@btinternet.com
If it ain't broke - don't fix it :)

MartinLiss
Nov 28th, 1999, 08:38 AM
I don't know if it makes a difference, but the right parenthesis in Altdown = (Shift And vbAltMask > 0) is placed differently than the others.

------------------
Marty

chrisjk
Nov 28th, 1999, 08:56 AM
So it is - I hadn't noticed! Thank you - i'll give it a shot.

Kind regards,

------------------
- Chris
chris.kilhams@btinternet.com
If it ain't broke - don't fix it :)

chrisjk
Nov 28th, 1999, 08:59 AM
unfortunately - it didn't make any difference (typical!!). Any ideas anyone?!

Thanks,

------------------
- Chris
chris.kilhams@btinternet.com
If it ain't broke - don't fix it :)