Results 1 to 5 of 5

Thread: Shortcut Keys dilema

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2007
    Location
    India
    Posts
    227

    Shortcut Keys dilema

    I don't know if I will be able to explain my problem or not. But let me try.

    I want to give facility to users to set their own shortcut keys for various commands in my software at runtime. Here the user should be able to even set a shortcut key for a button click so instead of clicking on the button the user can just press the shortcut key to execute that buttons click event.

    How can I do this? I mean how can I give user facility to set shortcut key for a particular event and execute the relevant code when the shortcut key is pressed...

    Say for example that a user sets a shortcut key for a button's click event. Now the software should show that shortcut key in the respective button's caption also...

    Ok that is it. I hope I have managed to explain my stuff properly?

    How can I do something like this.

    Someone please guide me here.

    Regards,

    Yogi Yang

  2. #2
    Just a Member! seenu_1st's Avatar
    Join Date
    Aug 2007
    Location
    India
    Posts
    2,170

    Re: Shortcut Keys dilema

    u can use KeyDown event, try like this
    Code:
    Private Sub Command1_Click()
    MsgBox "Hi"
    End Sub
    
    Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    If Shift = 2 And KeyCode = Asc("A") Then 'Ctrl+A
        Command1_Click
    End If
    End Sub
    
    Private Sub Form_Load()
    Me.KeyPreview = True
    End Sub
    there r some other methods also
    Seenu

    If this post is useful, pls don't forget to Rate this post.
    Pls mark thread as resolved once ur problem solved.
    ADO Tutorial Variable types SP6 for VB6, MsFlexGrid fast fill, Sorting Algorithms


  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Mar 2007
    Location
    India
    Posts
    227

    Re: Shortcut Keys dilema

    Quote Originally Posted by seenu_1st View Post
    u can use KeyDown event, try like this
    Code:
    Private Sub Command1_Click()
    MsgBox "Hi"
    End Sub
    
    Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    If Shift = 2 And KeyCode = Asc("A") Then 'Ctrl+A
        Command1_Click
    End If
    End Sub
    
    Private Sub Form_Load()
    Me.KeyPreview = True
    End Sub
    there r some other methods also
    Thanks for your help but I have already done this. But the keypreview does not work at times especially when a combo box has focus.

  4. #4
    Member
    Join Date
    Jun 2012
    Location
    San Pedro, Laguna, Philippines
    Posts
    62

    Re: Shortcut Keys dilema

    add & to your command button's caption.

  5. #5
    Just a Member! seenu_1st's Avatar
    Join Date
    Aug 2007
    Location
    India
    Posts
    2,170

    Re: Shortcut Keys dilema

    Quote Originally Posted by yogiyang View Post
    Thanks for your help but I have already done this. But the keypreview does not work at times especially when a combo box has focus.
    i tried with combobox too, it works fine, can u post ur code or attach the project as zip?
    Seenu

    If this post is useful, pls don't forget to Rate this post.
    Pls mark thread as resolved once ur problem solved.
    ADO Tutorial Variable types SP6 for VB6, MsFlexGrid fast fill, Sorting Algorithms


Tags for this Thread

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