Results 1 to 5 of 5

Thread: File1 problem

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2002
    Posts
    102

    File1 problem

    hi guys,

    i have a problem, i have made drive, dir, and file boxes all link together - thats fine, but i have also included a listbox wich receives the file names, and a rightclickable menu. when i right click the menu and select one of the options with the mouse it runs the code perfect, but if i use the keyboard eg ctrl + a, the file1 box doesent listen to the code.

    what have or havent i done?

    is there another way of doing this, eg using code within the file1 box to use shortcut keys?

    thanks
    aiden,
    [email protected]
    __________________
    The human race is a smart one, but we still don’t yet understand that if there is no food in the fridge the first time, there wont be food in the fridge the 2nd 3rd or hundredth time you check -- (…always hoping)

  2. #2
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    I assume you have Ctrl+A as a shortcut for one of the menu items and the main menu is set to be invisible, right? In that case VB will not react to the shortcuts you have assigned to the menu.

    The work around is to set the KeyPreview of the Form to True and check for all the shortcuts in the Form_KeyDown event.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Aug 2002
    Posts
    102
    so what code would i need to put in the keydown?
    aiden,
    [email protected]
    __________________
    The human race is a smart one, but we still don’t yet understand that if there is no food in the fridge the first time, there wont be food in the fridge the 2nd 3rd or hundredth time you check -- (…always hoping)

  4. #4
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    VB Code:
    1. Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    2.     If Shift = vbCtrlMask Then
    3.         'Shift can also have the values vbShiftMask or vbAltMask
    4.         'or a combination of them
    5.         Select Case KeyCode
    6.             Case vbKeyA
    7.                 'Code for Ctrl+A
    8.             Case vbKeyX 'change this to a key you use
    9.                 'cod for Ctrl+X
    10.             'add more case statements here
    11.         End Select
    12.     End If
    13. End Sub

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Aug 2002
    Posts
    102
    thanks for that, thats exactly what i was looking for.
    aiden,
    [email protected]
    __________________
    The human race is a smart one, but we still don’t yet understand that if there is no food in the fridge the first time, there wont be food in the fridge the 2nd 3rd or hundredth time you check -- (…always hoping)

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