Results 1 to 4 of 4

Thread: Trap keystrokes

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923

    Post

    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

  2. #2
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,427

    Post

    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

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923

    Post

    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

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923

    Post

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width