HardwareKeys (Enumeración)
Actualización: noviembre 2007
Especifica los botones de hardware de un Pocket PC al que puede tener acceso la clase HardwareButton.
Espacio de nombres: Microsoft.WindowsCE.Forms
Ensamblado: Microsoft.WindowsCE.Forms (en Microsoft.WindowsCE.Forms.dll)
Sintaxis
'Declaración
Public Enumeration HardwareKeys
'Uso
Dim instance As HardwareKeys
public enum HardwareKeys
public enum class HardwareKeys
public enum HardwareKeys
Miembros
Nombre de miembro | Descripción | |
---|---|---|
None | Especifica que no hay ningún botón de hardware real asociado a esta instancia de HardwareButton. | |
ApplicationKey1 | Especifica el botón de hardware que corresponde a la aplicación 1. | |
ApplicationKey2 | Especifica el botón de hardware que corresponde a la aplicación 2. | |
ApplicationKey3 | Especifica el botón de hardware que corresponde a la aplicación 3. | |
ApplicationKey4 | Especifica el botón de hardware que corresponde a la aplicación 4. | |
ApplicationKey5 | Especifica el botón de hardware que corresponde a la aplicación 5. | |
ApplicationKey6 | Especifica el botón de hardware que corresponde a la aplicación 6. |
Excepciones
Excepción | Condición |
---|---|
NotSupportedException |
Comentarios
El formulario o control asociado a un miembro de esta enumeración puede recibir los eventos KeyDowny KeyUp cuando se presiona el botón de hardware correspondiente.
Esta enumeración no es compatible e inicia una excepción NotSupportedException respecto de Smartphone y los demás dispositivos de Windows CE que no sean Pocket PC.
Ejemplos
El ejemplo de código siguiente utiliza las propiedades AssociatedControl y HardwareKey para mostrar un formulario cada vez que se presionen los botones primero y cuarto de su Pocket PC. Este ejemplo de código forma parte de un ejemplo más amplio proporcionado por la clase HardwareButton.
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()
hwb4 = 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
hwb4.AssociatedControl = Me
hwb1.HardwareKey = HardwareKeys.ApplicationKey1
hwb4.HardwareKey = HardwareKeys.ApplicationKey4
Catch exc As Exception
MessageBox.Show(exc.Message + " Check if the hardware button is physically available on this device.")
End Try
End Sub
Private Overloads Sub OnKeyUp(sender As Object, e As KeyEventArgs) Handles MyBase.KeyUp
' When a hardware button is pressed and released,
' this form receives the KeyUp event. The OnKeyUp
' method is used to determine which hardware
' button was pressed, because the event data
' specifies a member of the HardwareKeys enumeration.
Select Case CType(e.KeyCode, HardwareKeys)
Case HardwareKeys.ApplicationKey1
statusBar1.Text = "Button 1 pressed."
Case HardwareKeys.ApplicationKey4
statusBar1.Text = "Button 4 pressed."
Case Else
End Select
End Sub
// Configure hardware buttons
// 1 and 4 to activate the current form.
private void HBConfig()
{
try
{
hwb1 = new HardwareButton();
hwb4 = new HardwareButton();
hwb1.AssociatedControl = this;
hwb4.AssociatedControl = this;
hwb1.HardwareKey = HardwareKeys.ApplicationKey1;
hwb4.HardwareKey = HardwareKeys.ApplicationKey4;
}
catch (Exception exc)
{
MessageBox.Show(exc.Message + " Check if the hardware button is physically available on this device.");
}
}
// When a hardware button is pressed and released,
// this form receives the KeyUp event. The OnKeyUp
// method is used to determine which hardware
// button was pressed, because the event data
// specifies a member of the HardwareKeys enumeration.
private void OnKeyUp(object sender, KeyEventArgs e)
{
switch ((HardwareKeys)e.KeyCode)
{
case HardwareKeys.ApplicationKey1:
statusBar1.Text = "Button 1 pressed.";
break;
case HardwareKeys.ApplicationKey4:
statusBar1.Text = "Button 4 pressed.";
break;
default:
break;
}
}
Plataformas
Windows CE, Windows Mobile para Smartphone, Windows Mobile para Pocket PC
.NET Framework y .NET Compact Framework no admiten todas las versiones de cada plataforma. Para obtener una lista de las versiones compatibles, vea Requisitos de sistema de .NET Framework.
Información de versión
.NET Compact Framework
Compatible con: 3.5, 2.0
Vea también
Referencia
Microsoft.WindowsCE.Forms (Espacio de nombres)