G
Guest
Is anyone else haveing problems with the hardware buttons in V2? I can't get
them to activate anything but what is set up in the OS.
Here's the code I'm testing.
------------------
Imports Microsoft.WindowsCE.Forms
Public Class Form1
Private Sub ConfigHWButton()
' Set KeyPreview to true so that the form
' will receive key events before they
' are passed to the control that has focus.
Me.KeyPreview = True
hwb1 = New HardwareButton()
hwb2 = New HardwareButton()
' Set the AssociatedControl property
' to the current form and configure the
' first and fourth buttons to activate the form.
Try
hwb1.AssociatedControl = Me
hwb2.AssociatedControl = Me
hwb1.HardwareKey = HardwareKeys.ApplicationKey1
hwb2.HardwareKey = HardwareKeys.ApplicationKey2
Catch exc As Exception
MsgBox(exc.Message & " Check if the hardware button is " & _
"physically available on this device.")
End Try
End Sub
Private Sub Form1_Activated(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Activated
ConfigHWButton()
End Sub
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
Select Case CType(e.KeyCode, HardwareKeys)
Case HardwareKeys.ApplicationKey1
MsgBox("1")
Case HardwareKeys.ApplicationKey2
MsgBox("2")
End Select
End Sub
End Class
them to activate anything but what is set up in the OS.
Here's the code I'm testing.
------------------
Imports Microsoft.WindowsCE.Forms
Public Class Form1
Private Sub ConfigHWButton()
' Set KeyPreview to true so that the form
' will receive key events before they
' are passed to the control that has focus.
Me.KeyPreview = True
hwb1 = New HardwareButton()
hwb2 = New HardwareButton()
' Set the AssociatedControl property
' to the current form and configure the
' first and fourth buttons to activate the form.
Try
hwb1.AssociatedControl = Me
hwb2.AssociatedControl = Me
hwb1.HardwareKey = HardwareKeys.ApplicationKey1
hwb2.HardwareKey = HardwareKeys.ApplicationKey2
Catch exc As Exception
MsgBox(exc.Message & " Check if the hardware button is " & _
"physically available on this device.")
End Try
End Sub
Private Sub Form1_Activated(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Activated
ConfigHWButton()
End Sub
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
Select Case CType(e.KeyCode, HardwareKeys)
Case HardwareKeys.ApplicationKey1
MsgBox("1")
Case HardwareKeys.ApplicationKey2
MsgBox("2")
End Select
End Sub
End Class