Results 1 to 7 of 7

Thread: PopupMenus & Shortcut Keys

  1. #1

    Thread Starter
    PowerPoster Arc's Avatar
    Join Date
    Sep 2000
    Location
    Under my rock
    Posts
    2,336

    PopupMenus & Shortcut Keys

    I have a problem with using shortcut keys in a hidden menu.

    I am using a label to popup up the menu when clicked. In the menu are shorcut keys for various things. They Don't work unless i make the menu Visible, which i don't want for esthetic reasons.

    Anyway to make a non visible menu respond to Shortcut keys?
    -We have enough youth. How about a fountain of "Smart"?
    -If you can read this, thank a teacher....and since it's in English, thank a soldier.


  2. #2
    DaoK
    Guest
    What is the code you are using ?

  3. #3
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    No you have to handle the Shortcuts through code.
    You can do this in the KeyDown event of your Form if you set the KeyPreview property to True.
    Let say, for example, that you have 3 menu items in the hidden popup menu and the items are called mnuPop1, mnuPop2 and mnuPop3.
    To these menu items you've added Ctrl+A, Ctrl+B and Ctrl+C as the shortcuts.
    Then add the following code in the KeyDown event of the Form (remember that KeyPreview must be True)
    VB Code:
    1. Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    2.     If (Shift And vbCtrlMask) = vbCtrlMask Then
    3.         Select Case KeyCode
    4.             Case vbKeyA
    5.                 mnuPop1_Click
    6.             Case vbKeyB
    7.                 mnuPop2_Click
    8.             Case vbKeyC
    9.                 mnuPop3_Click
    10.         End Select
    11.     End If
    12. End Sub
    Best regards

  4. #4

    Thread Starter
    PowerPoster Arc's Avatar
    Join Date
    Sep 2000
    Location
    Under my rock
    Posts
    2,336
    Thanks alot. Any idea what the Keycode is for the F keys? I.e. F1 F2 F3 ect...
    -We have enough youth. How about a fountain of "Smart"?
    -If you can read this, thank a teacher....and since it's in English, thank a soldier.


  5. #5
    DaoK
    Guest
    vbkeyf1 ?

  6. #6
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    Yes DaoK is correct. The function keys are simply vbKeyF1 to vbKeyF12

  7. #7

    Thread Starter
    PowerPoster Arc's Avatar
    Join Date
    Sep 2000
    Location
    Under my rock
    Posts
    2,336
    Thanks alot guys.. works perfectly.
    -We have enough youth. How about a fountain of "Smart"?
    -If you can read this, thank a teacher....and since it's in English, thank a soldier.


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