Hi,
this is the code that works for me, slightly changed from the original
Thanks
Pete
Imports System.Runtime.InteropServices
Imports System.Windows.Forms
Public Class Form1
Inherits System.Windows.Forms.Form
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents MainMenu1 As System.Windows.Forms.MainMenu
Enum InputMode As Integer
IM_SPELL = &H0
IM_AMBIG = &H1
IM_NUMBERS = &H2
End Enum
<System.Runtime.InteropServices.DllImport("coredll.dll")> _
Public Shared Function GetCapture() As IntPtr
End Function
<System.Runtime.InteropServices.DllImport("coredll.dll")> _
Public Shared Function GetFocus() As IntPtr
End Function
Sub SetInputMode(ByVal InputMode As InputMode, ByVal Control As
Windows.Forms.Control)
Const EM_SETINPUTMODE As Integer = &HDE
Dim wparam As New IntPtr(0)
Dim lparam As New IntPtr(InputMode)
Dim msg As New Microsoft.WindowsCE.Forms.Message
Dim container As New Microsoft.WindowsCE.Forms.MessageWindow
Control.Capture = True
'Dim hWnd As IntPtr = GetCapture()
Dim hWnd As IntPtr = GetFocus()
Control.Capture = False
msg = Microsoft.WindowsCE.Forms.Message.Create(hWnd,
EM_SETINPUTMODE, wparam, lparam)
container.PostMessage(msg)
End Sub
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
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.
Private Sub InitializeComponent()
Me.MainMenu1 = New System.Windows.Forms.MainMenu
Me.TextBox1 = New System.Windows.Forms.TextBox
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(16, 40)
Me.TextBox1.Size = New System.Drawing.Size(142, 25)
Me.TextBox1.Text = ""
'
'Form1
'
Me.Controls.Add(Me.TextBox1)
Me.Menu = Me.MainMenu1
Me.Text = "Form1"
End Sub
#End Region
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
SetInputMode(InputMode.IM_NUMBERS, TextBox1)
End Sub
End Class
--
Pete Vickers
Microsoft Windows Embedded MVP
HP Business Partner
http://www.gui-innovations.com
Mike said:
Could you show me some code? I tried making the change myself and
still have no luck. Thanks for all your help.
-Mike-
"Pete Vickers [eMVP]" <pete at gui - innovations dot com> wrote in message
Hi,
i just changed the getcapture to getfocus and it worked fine - i have a
working sample if you need it
Pete
--
Pete Vickers
Microsoft Windows Embedded MVP
HP Business Partner
http://www.gui-innovations.com
That code doesn't seem to work.
One weird thing is that the line:
container.PostMessage(msg)
produces a syntax error because PostMessage is a static/Shared method
of Microsoft.WindowsCE.Forms.MessageWindow. So I replaced the instance
reference "container" with a static call and the text controls still
insist on multi-tap input instead of numeric.
-Mike-
"Pete Vickers [eMVP]" <pete at gui - innovations dot com> wrote in
message
Hi,
sorry - just found the best way -
http://groups.google.com/groups?hl=...ge&ie=UTF-8&oe=UTF-8&hl=en&btnG=Google+Search
Pete
--
Pete Vickers
Microsoft Windows Embedded MVP
HP Business Partner
http://www.gui-innovations.com
This has probably been asked before (I can't imagine anyone never
needing one of these) but I haven't found any good info on it yet...
Basically I need an input box that only accepts numbers. So when the
user hits the 2 key on the phone it will input a '2' character into
the box instead of the normal multi-tap 'a'/'b'/'c'/'2' characters. I
imagine that the 1 key could possibly enter a '.' character. In any
case, I am surprised that there isn't a property of TextBox to do
this. Does anyone know if this functionality exists in the .NET
Compact Framework but is buried? Or is there a popular custom control
(free preferably) that does it? I'd like to avoid writing my own
control to do it though I suppose that it is a last resort...
-Mike-