By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,990 Members | 2,279 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,990 IT Pros & Developers. It's quick & easy.

Hotkey type scenerio

P: n/a
I have an application thats a viewer. I also have a form that is fired from
a Tools/Options menu selection. In the Options form the user can select a
hotkey to use to exit the main viewer application. On the Options form I
have a textbox that the user can use to enter the key he would like to use
as the hotkey. I want to allow the hotkey to be letters, numbers and the
control keys. When the textbox has focus and the user selects a letter or
number key it should be displayed in the textbox (pretty simple). If they
select a control key it should display some sort of representation (I can
define these) such as "CTRL" for the control key. Lastly, the user should
only be allowed one keypress while in the textbox. I quess subsiquent
keypresses shoul overwrite the previous keypress.

Also, where can I get a list of all the control keys?

Any ideas what I need to do here,
John
Nov 20 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
"jcrouse" <me> wrote in message
news:Os**************@TK2MSFTNGP10.phx.gbl...
I have an application thats a viewer. I also have a form that is fired from a Tools/Options menu selection. In the Options form the user can select a
hotkey to use to exit the main viewer application. On the Options form I
have a textbox that the user can use to enter the key he would like to use
as the hotkey. I want to allow the hotkey to be letters, numbers and the
control keys. When the textbox has focus and the user selects a letter or
number key it should be displayed in the textbox (pretty simple). If they
select a control key it should display some sort of representation (I can
define these) such as "CTRL" for the control key. Lastly, the user should
only be allowed one keypress while in the textbox. I quess subsiquent
keypresses shoul overwrite the previous keypress.

Also, where can I get a list of all the control keys?

Any ideas what I need to do here,
John


Have a look at the MenuItem.Shortcut property. The key (pun intended) to
what you are looking for lies in the associated type converter for this.
I've never seen much documented on it, but I guess since the enumeration is
serializable, it is used internally by the IDE for code generation? And now
also by you. :-)

Stick this in some code, and type a period after it to see the goodies that
come up. I think it will help you get where you are going.

System.ComponentModel.TypeDescriptor.GetConverter( GetType(Shortcut))

Best Regards,

Andy
Nov 20 '05 #2

P: n/a
Here's the direction I'm headed.

Private Sub txtExitKey_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles txtExitKey.KeyPress

If Char.IsLetterOrDigit(e.KeyChar) Then

txtExitKey.SelectionStart = 0

txtExitKey.SelectionLength = Len(txtExitKey.Text)

ElseIf Char.IsControl(e.KeyChar) Then

Select Case e.KeyChar

Case Microsoft.VisualBasic.ChrW(27)

txtExitKey.Text = "Esc"

Case Microsoft.VisualBasic.ChrW(9)

txtExitKey.Text = "Tab"

Case Microsoft.VisualBasic.ChrW(13)

txtExitKey.Text = "Enter"

Case Microsoft.VisualBasic.ChrW(16)

txtExitKey.Text = "Shift"

Case Microsoft.VisualBasic.ChrW(17)

txtExitKey.Text = "Ctrl"

Case Microsoft.VisualBasic.ChrW(19)

txtExitKey.Text = "Pause"

Case Microsoft.VisualBasic.ChrW(20)

txtExitKey.Text = "Caps Lock"

Case Microsoft.VisualBasic.ChrW(32)

txtExitKey.Text = "Spacebar"

Case Microsoft.VisualBasic.ChrW(33)

txtExitKey.Text = "Page Up"

Case Microsoft.VisualBasic.ChrW(34)

txtExitKey.Text = "Page Down"

Case Microsoft.VisualBasic.ChrW(35)

txtExitKey.Text = "End"

Case Microsoft.VisualBasic.ChrW(36)

txtExitKey.Text = "Home"

Case Microsoft.VisualBasic.ChrW(37)

txtExitKey.Text = "Left Arrow"

Case Microsoft.VisualBasic.ChrW(38)

txtExitKey.Text = "Up Arrow"

Case Microsoft.VisualBasic.ChrW(39)

txtExitKey.Text = "Right Arrow"

Case Microsoft.VisualBasic.ChrW(40)

txtExitKey.Text = "Down Arrow"

Case Microsoft.VisualBasic.ChrW(42)

txtExitKey.Text = "Print Screen"

Case Microsoft.VisualBasic.ChrW(45)

txtExitKey.Text = "Insert"

Case Microsoft.VisualBasic.ChrW(46)

txtExitKey.Text = "Delete"

Case Microsoft.VisualBasic.ChrW(144)

txtExitKey.Text = "Num Lock"

Case Microsoft.VisualBasic.ChrW(112)

txtExitKey.Text = "F1"

Case Microsoft.VisualBasic.ChrW(113)

txtExitKey.Text = "F2"

Case Microsoft.VisualBasic.ChrW(114)

txtExitKey.Text = "F3"

Case Microsoft.VisualBasic.ChrW(115)

txtExitKey.Text = "F4"

Case Microsoft.VisualBasic.ChrW(116)

txtExitKey.Text = "F5"

Case Microsoft.VisualBasic.ChrW(117)

txtExitKey.Text = "F6"

Case Microsoft.VisualBasic.ChrW(118)

txtExitKey.Text = "F7"

Case Microsoft.VisualBasic.ChrW(119)

txtExitKey.Text = "F8"

Case Microsoft.VisualBasic.ChrW(120)

txtExitKey.Text = "F9"

Case Microsoft.VisualBasic.ChrW(121)

txtExitKey.Text = "F10"

Case Microsoft.VisualBasic.ChrW(122)

txtExitKey.Text = "F11"

Case Microsoft.VisualBasic.ChrW(123)

txtExitKey.Text = "F12"

Case Else

Dim response As String

response = MsgBox("That key is not supported.",
vbCritical, "CPViewer")

txtExitKey.Focus()

End Select

End If

End Sub

Private Sub txtExitKey_KeyUp(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles txtExitKey.KeyUp

txtExitKey.SelectAll()

End Sub

This isn't working however. Also, I need to distinguish between the left and
right Shift, Alt and Ctrl keys. Also, when done, I need to somehow write it
out to aN XML file in some format that my app can read back in the next time
it's launched. I have the XML working for digits and numbers but am not sure
what kink this will throw into things.

Thanks,
John

PS...I REALLY hate .Net !!!!
"jcrouse" <me> wrote in message
news:Os**************@TK2MSFTNGP10.phx.gbl...
I have an application thats a viewer. I also have a form that is fired from a Tools/Options menu selection. In the Options form the user can select a
hotkey to use to exit the main viewer application. On the Options form I
have a textbox that the user can use to enter the key he would like to use
as the hotkey. I want to allow the hotkey to be letters, numbers and the
control keys. When the textbox has focus and the user selects a letter or
number key it should be displayed in the textbox (pretty simple). If they
select a control key it should display some sort of representation (I can
define these) such as "CTRL" for the control key. Lastly, the user should
only be allowed one keypress while in the textbox. I quess subsiquent
keypresses shoul overwrite the previous keypress.

Also, where can I get a list of all the control keys?

Any ideas what I need to do here,
John

Nov 20 '05 #3

P: n/a
Check out the Keys class, it has enumeration members which is what u need.

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing

"jcrouse" <me> wrote in message
news:Os**************@TK2MSFTNGP10.phx.gbl...
I have an application thats a viewer. I also have a form that is fired from a Tools/Options menu selection. In the Options form the user can select a
hotkey to use to exit the main viewer application. On the Options form I
have a textbox that the user can use to enter the key he would like to use
as the hotkey. I want to allow the hotkey to be letters, numbers and the
control keys. When the textbox has focus and the user selects a letter or
number key it should be displayed in the textbox (pretty simple). If they
select a control key it should display some sort of representation (I can
define these) such as "CTRL" for the control key. Lastly, the user should
only be allowed one keypress while in the textbox. I quess subsiquent
keypresses shoul overwrite the previous keypress.

Also, where can I get a list of all the control keys?

Any ideas what I need to do here,
John

Nov 20 '05 #4

P: n/a
Resolved !

"jcrouse" <me> wrote in message
news:Os**************@TK2MSFTNGP10.phx.gbl...
I have an application thats a viewer. I also have a form that is fired from a Tools/Options menu selection. In the Options form the user can select a
hotkey to use to exit the main viewer application. On the Options form I
have a textbox that the user can use to enter the key he would like to use
as the hotkey. I want to allow the hotkey to be letters, numbers and the
control keys. When the textbox has focus and the user selects a letter or
number key it should be displayed in the textbox (pretty simple). If they
select a control key it should display some sort of representation (I can
define these) such as "CTRL" for the control key. Lastly, the user should
only be allowed one keypress while in the textbox. I quess subsiquent
keypresses shoul overwrite the previous keypress.

Also, where can I get a list of all the control keys?

Any ideas what I need to do here,
John

Nov 20 '05 #5

P: n/a
Resolved !

"jcrouse" <me> wrote in message
news:Os**************@TK2MSFTNGP10.phx.gbl...
I have an application thats a viewer. I also have a form that is fired from a Tools/Options menu selection. In the Options form the user can select a
hotkey to use to exit the main viewer application. On the Options form I
have a textbox that the user can use to enter the key he would like to use
as the hotkey. I want to allow the hotkey to be letters, numbers and the
control keys. When the textbox has focus and the user selects a letter or
number key it should be displayed in the textbox (pretty simple). If they
select a control key it should display some sort of representation (I can
define these) such as "CTRL" for the control key. Lastly, the user should
only be allowed one keypress while in the textbox. I quess subsiquent
keypresses shoul overwrite the previous keypress.

Also, where can I get a list of all the control keys?

Any ideas what I need to do here,
John

Nov 20 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.