|
-
Jun 23rd, 2012, 08:18 AM
#1
Thread Starter
Addicted Member
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
-
Jun 23rd, 2012, 08:32 AM
#2
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
-
Jun 26th, 2012, 12:00 AM
#3
Thread Starter
Addicted Member
Re: Shortcut Keys dilema
 Originally Posted by seenu_1st
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.
-
Jun 26th, 2012, 12:03 AM
#4
Member
Re: Shortcut Keys dilema
add & to your command button's caption.
-
Jun 26th, 2012, 12:33 AM
#5
Re: Shortcut Keys dilema
 Originally Posted by yogiyang
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?
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|