Here's the direction I'm headed.
Private Sub txtExitKey_KeyP ress(ByVal sender As Object, ByVal e As
System.Windows. Forms.KeyPressE ventArgs) Handles txtExitKey.KeyP ress
If Char.IsLetterOr Digit(e.KeyChar ) Then
txtExitKey.Sele ctionStart = 0
txtExitKey.Sele ctionLength = Len(txtExitKey. Text)
ElseIf Char.IsControl( e.KeyChar) Then
Select Case e.KeyChar
Case Microsoft.Visua lBasic.ChrW(27)
txtExitKey.Text = "Esc"
Case Microsoft.Visua lBasic.ChrW(9)
txtExitKey.Text = "Tab"
Case Microsoft.Visua lBasic.ChrW(13)
txtExitKey.Text = "Enter"
Case Microsoft.Visua lBasic.ChrW(16)
txtExitKey.Text = "Shift"
Case Microsoft.Visua lBasic.ChrW(17)
txtExitKey.Text = "Ctrl"
Case Microsoft.Visua lBasic.ChrW(19)
txtExitKey.Text = "Pause"
Case Microsoft.Visua lBasic.ChrW(20)
txtExitKey.Text = "Caps Lock"
Case Microsoft.Visua lBasic.ChrW(32)
txtExitKey.Text = "Spacebar"
Case Microsoft.Visua lBasic.ChrW(33)
txtExitKey.Text = "Page Up"
Case Microsoft.Visua lBasic.ChrW(34)
txtExitKey.Text = "Page Down"
Case Microsoft.Visua lBasic.ChrW(35)
txtExitKey.Text = "End"
Case Microsoft.Visua lBasic.ChrW(36)
txtExitKey.Text = "Home"
Case Microsoft.Visua lBasic.ChrW(37)
txtExitKey.Text = "Left Arrow"
Case Microsoft.Visua lBasic.ChrW(38)
txtExitKey.Text = "Up Arrow"
Case Microsoft.Visua lBasic.ChrW(39)
txtExitKey.Text = "Right Arrow"
Case Microsoft.Visua lBasic.ChrW(40)
txtExitKey.Text = "Down Arrow"
Case Microsoft.Visua lBasic.ChrW(42)
txtExitKey.Text = "Print Screen"
Case Microsoft.Visua lBasic.ChrW(45)
txtExitKey.Text = "Insert"
Case Microsoft.Visua lBasic.ChrW(46)
txtExitKey.Text = "Delete"
Case Microsoft.Visua lBasic.ChrW(144 )
txtExitKey.Text = "Num Lock"
Case Microsoft.Visua lBasic.ChrW(112 )
txtExitKey.Text = "F1"
Case Microsoft.Visua lBasic.ChrW(113 )
txtExitKey.Text = "F2"
Case Microsoft.Visua lBasic.ChrW(114 )
txtExitKey.Text = "F3"
Case Microsoft.Visua lBasic.ChrW(115 )
txtExitKey.Text = "F4"
Case Microsoft.Visua lBasic.ChrW(116 )
txtExitKey.Text = "F5"
Case Microsoft.Visua lBasic.ChrW(117 )
txtExitKey.Text = "F6"
Case Microsoft.Visua lBasic.ChrW(118 )
txtExitKey.Text = "F7"
Case Microsoft.Visua lBasic.ChrW(119 )
txtExitKey.Text = "F8"
Case Microsoft.Visua lBasic.ChrW(120 )
txtExitKey.Text = "F9"
Case Microsoft.Visua lBasic.ChrW(121 )
txtExitKey.Text = "F10"
Case Microsoft.Visua lBasic.ChrW(122 )
txtExitKey.Text = "F11"
Case Microsoft.Visua lBasic.ChrW(123 )
txtExitKey.Text = "F12"
Case Else
Dim response As String
response = MsgBox("That key is not supported.",
vbCritical, "CPViewer")
txtExitKey.Focu s()
End Select
End If
End Sub
Private Sub txtExitKey_KeyU p(ByVal sender As Object, ByVal e As
System.Windows. Forms.KeyEventA rgs) Handles txtExitKey.KeyU p
txtExitKey.Sele ctAll()
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******** ******@TK2MSFTN GP10.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