HardwareKeys 列挙体
[このドキュメントはプレビュー版であり、後のリリースで変更されることがあります。 空白のトピックは、プレースホルダーとして挿入されています。]
HardwareButton クラスによってアクセスできる Pocket PC のハードウェア ボタンを指定します。
名前空間: Microsoft.WindowsCE.Forms
アセンブリ: Microsoft.WindowsCE.Forms (Microsoft.WindowsCE.Forms.dll 内)
構文
'宣言
Public Enumeration HardwareKeys
'使用
Dim instance As HardwareKeys
public enum HardwareKeys
public enum class HardwareKeys
type HardwareKeys
メンバー
メンバー名 | 説明 | |
---|---|---|
None | 実際のハードウェア ボタンが、この HardwareButton インスタンスに関連付けられていないことを指定します。 | |
ApplicationKey1 | アプリケーション 1 に対応するハードウェア ボタンを指定します。 | |
ApplicationKey2 | アプリケーション 2 に対応するハードウェア ボタンを指定します。 | |
ApplicationKey3 | アプリケーション 3 に対応するハードウェア ボタンを指定します。 | |
ApplicationKey4 | アプリケーション 4 に対応するハードウェア ボタンを指定します。 | |
ApplicationKey5 | アプリケーション 5 に対応するハードウェア ボタンを指定します。 | |
ApplicationKey6 | アプリケーション 6 に対応するハードウェア ボタンを指定します。 |
例外
例外 | 条件 |
---|---|
NotSupportedException |
解説
この列挙体のメンバーに関連付けられたフォームまたはコントロールは、対応するハードウェア ボタンが押されたときに、KeyDown イベントおよび KeyUp イベントを受け取ることができます。
注意
ハードウェア ボタンは、Pocket PC でアプリケーション キーに対応します。アプリケーション キーはへ 1 つのキーボード レイアウトからによって異なりますがハードウェア キー マッピングのため、コア キー セットに含まれません。のみ既定のハードウェア キー マッピング デバイスではサポートされています。
この列挙体は、Smartphone および Pocket PC 以外の Windows CE デバイスではサポートされていないため、NotSupportedException がスローされます。
例
AssociatedControl プロパティと HardwareKey プロパティを使用して、Pocket PC の 1 つ目のボタンと 4 つ目のボタンが押されるたびにフォームを表示するコード例を次に示します。このコード例は、HardwareButton クラスのトピックで取り上げているコード例の一部分です。
PrivateSub 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.")
EndTryEndSubPrivateOverloadsSub OnKeyUp(sender AsObject, e As KeyEventArgs) HandlesMyBase.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.SelectCaseCType(e.KeyCode, HardwareKeys)
Case HardwareKeys.ApplicationKey1
statusBar1.Text = "Button 1 pressed."Case HardwareKeys.ApplicationKey4
statusBar1.Text = "Button 4 pressed."CaseElseEndSelectEndSub
// Configure hardware buttons// 1 and 4 to activate the current form.privatevoid 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.privatevoid 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;
}
}
プラットフォーム
Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC
.NET Framework および .NET Compact Framework では、各プラットフォームのすべてのバージョンはサポートしていません。 サポートされているバージョンについては、「.NET フレームワークのシステム要件」を参照してください。
バージョン情報
.NET Compact Framework
サポート対象 : 3.5、2.0
参照
参照
Microsoft.WindowsCE.Forms 名前空間