Many thanks,
I give it a try.
Jason.
On Fri, 3 Sep 2004 07:35:02 -0700, "=?Utf-8?B?cHJha2FzaA==?="
<(E-Mail Removed)> wrote:
>Hi Jason L James
>Try this code . it is for handling the hardware keys of a PPC Device
>-------------------------------------------
>Imports System
>Imports System.Drawing
>Imports System.Collections
>Imports System.ComponentModel
>Imports System.Windows.Forms
>Imports Microsoft.WindowsCE.Forms
>Imports System.Runtime.InteropServices
>
>Namespace HardwareButtons
>
> Public Enum KeyModifiers As Integer
> None = 0
> Alt = 1
> Control = 2
> Shift = 4
> Windows = 8
> Modkeyup = &H1000
> End Enum
>
> Public Enum KeysHardware As Integer
> Hardware1 = 193
> Hardware2 = 194
> Hardware3 = 195
> Hardware4 = 196
> Hardware5 = 202
>
> End Enum
> Public Module RegisterHKeys
>
> <DllImport("coredll.dll", Entrypoint:="RegisterHotKey",
>setLastError:=True)> _
> Public Function RegisterHotKey( _
> ByVal hWnd As IntPtr, _
> ByVal id As Integer, _
> ByVal Modifiers As HardwareButtons.KeyModifiers, _
> ByVal key As Integer) As Boolean
> End Function
>
> <DllImport("coredll.dll")> _
> Private Function UnregisterFunc1( _
> ByVal modifiers As HardwareButtons.KeyModifiers, _
> ByVal keyID As Integer) As Boolean
> End Function
>
> Public Sub RegisterRecordKey(ByVal hWnd As IntPtr)
> UnregisterFunc1(HardwareButtons.KeyModifiers.Windows,
>CType(HardwareButtons.KeysHardware.Hardware1, Integer))
> RegisterHotKey(hWnd,
>CType(HardwareButtons.KeysHardware.Hardware1, Integer),
>HardwareButtons.KeyModifiers.Windows,
>CType(HardwareButtons.KeysHardware.Hardware1, Integer))
>
> UnregisterFunc1(HardwareButtons.KeyModifiers.Windows,
>CType(HardwareButtons.KeysHardware.Hardware2, Integer))
> RegisterHotKey(hWnd,
>CType(HardwareButtons.KeysHardware.Hardware2, Integer),
>HardwareButtons.KeyModifiers.Windows,
>CType(HardwareButtons.KeysHardware.Hardware2, Integer))
>
> UnregisterFunc1(HardwareButtons.KeyModifiers.Windows,
>CType(HardwareButtons.KeysHardware.Hardware3, Integer))
> RegisterHotKey(hWnd,
>CType(HardwareButtons.KeysHardware.Hardware3, Integer),
>HardwareButtons.KeyModifiers.Windows,
>CType(HardwareButtons.KeysHardware.Hardware3, Integer))
>
> UnregisterFunc1(HardwareButtons.KeyModifiers.Windows,
>CType(HardwareButtons.KeysHardware.Hardware4, Integer))
> RegisterHotKey(hWnd,
>CType(HardwareButtons.KeysHardware.Hardware4, Integer),
>HardwareButtons.KeyModifiers.Windows,
>CType(HardwareButtons.KeysHardware.Hardware4, Integer))
>
> UnregisterFunc1(HardwareButtons.KeyModifiers.Windows,
>CType(HardwareButtons.KeysHardware.Hardware5, Integer))
> RegisterHotKey(hWnd,
>CType(HardwareButtons.KeysHardware.Hardware5, Integer),
>HardwareButtons.KeyModifiers.Windows,
>CType(HardwareButtons.KeysHardware.Hardware5, Integer))
> End Sub
> End Module
> Public Class HButton
> Inherits System.Windows.Forms.Form
> Dim messageWindow As myMessageWindow
>
>#Region " Windows Form Designer generated code "
> Public Shared Sub Main()
> Application.Run(New HButton)
> End Sub
> Public Sub New()
> MyBase.New()
>
> 'This call is required by the Windows Form Designer.
> InitializeComponent()
>
> 'Add any initialization after the InitializeComponent() call
> Me.messageWindow = New myMessageWindow(Me)
> RegisterHKeys.RegisterRecordKey(Me.messageWindow.Hwnd)
> End Sub
>
> Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
> MyBase.Dispose(disposing)
> End Sub
>
> 'NOTE: The following procedure is required by the Windows Form
>Designer
> 'It can be modified using the Windows Form Designer.
> 'Do not modify it using the code editor.
> <System.Diagnostics.DebuggerStepThrough()> Private Sub
>InitializeComponent()
> '
> 'HButton
> '
> Me.Text = "HButton"
>
> End Sub
>
>#End Region
> Public Sub ButtonPressed(ByVal button As Integer)
> Select Case button
> Case HardwareButtons.KeysHardware.Hardware1
> MessageBox.Show("Button 1 pressed!")
> Exit Sub
> Case HardwareButtons.KeysHardware.Hardware2
> MessageBox.Show("Button 2 pressed!")
> Exit Sub
> Case HardwareButtons.KeysHardware.Hardware3
> MessageBox.Show("Button 3 pressed!")
> Exit Sub
> Case HardwareButtons.KeysHardware.Hardware4
> MessageBox.Show("Button 4 pressed!")
> Exit Sub
> Case HardwareButtons.KeysHardware.Hardware5
> MessageBox.Show("Button 5 pressed!")
> Exit Sub
> End Select
> End Sub
> Public Class myMessageWindow
> Inherits messageWindow
>
> Public Const WM_HOTKEY = &H312
> Dim example As HButton
> Public Sub New(ByVal example As HButton)
> Me.example = example
> End Sub
>
> Protected Overrides Sub WndProc(ByRef msg As Message)
> Select Case msg.Msg
> Case WM_HOTKEY
> example.ButtonPressed(msg.WParam.ToInt32())
> Return
> End Select
> MyBase.WndProc(msg)
> End Sub
> End Class
> End Class
>End Namespace
>------------------------------------------------------
>
>
>
>"Jason L James" wrote:
>
>> Hi all,
>>
>> does anyone know how to use the device buttons, not
>> screen buttons in my VB CF .Net code?
>>
>> Thanks,
>>
>> Jason.
>>