Results 1 to 5 of 5

Thread: Shortcut keys in program

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2000
    Posts
    11
    How do I create shortcut key for various subroutines in my programs? It's like those you can set at the Menu Editor for menus, eg. Ctrl-A, F2, etc...

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Code:
    Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
        Caption = KeyCode & "," & Shift
        If KeyCode = vbKeyF1 And Shift = 0 Then
            'F1 and no mask keys pressed
        End If
        If KeyCode = Asc("A") And Shift = 2 Then
            'A and Ctrl pressed
        End If
    keys
    End Sub
    check out keydown event in vb-help for combining your own mask
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3

    Thread Starter
    New Member
    Join Date
    Sep 2000
    Posts
    11
    I've tried that, but it doesn't work...
    Somehow the program doesn't even repsond to the keydown event (I've tried putting a breakpoint inside Form_KeyDown). Does it have to do with the focus or something?

  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Oh yeah, it's the focus. Set Keypreview to true on the form, and it will catch the key events from your controls in focus too.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  5. #5

    Thread Starter
    New Member
    Join Date
    Sep 2000
    Posts
    11
    Works great now! Thanks a lot!

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