Guest alhabibam Posted April 19, 2005 Report Posted April 19, 2005 Hi all, Does anyone know how to change the input mode of the mobile (Alphapet --> Numeric) for a specific text field? I wnat to create a text field that should accept only numbers. Thanks.
Guest mgama Posted April 19, 2005 Report Posted April 19, 2005 Hi all, Does anyone know how to change the input mode of the mobile (Alphapet --> Numeric) for a specific text field? I wnat to create a text field that should accept only numbers. Thanks. <{POST_SNAPBACK}> You can read through OpennetCF to find out how they do it. Search for SetInputMode.
Guest vman69 Posted April 21, 2005 Report Posted April 21, 2005 Hopefully the following code will help you out. I use it in some of the apps I am writing and it works well for me. using System; using System.Windows.Forms; using System.Runtime.InteropServices; namespace SmartAustralianPropertyFeeCalculator { public enum InputMode : ushort { Spell = 0, T9 = 1, Numeric = 2, Text = 3, }; /// /// This class will facilitate the ability to /// change the input type for a field. /// The standard are: /// T9 /// Numeric /// Text /// public class InputChanger { [DllImport("coredll",EntryPoint="GetCapture")] static extern IntPtr GetCapture(); [DllImport("coredll",EntryPoint="GetWindow")] static extern IntPtr GetWindow(IntPtr hWnd, int uCmd); [DllImport("coredll",EntryPoint="SendMessage")] static extern IntPtr SendMessage(IntPtr hWnd, ushort msg, ushort wParam, ushort lParam); /// /// Set the input mode for a control that is passed. /// /// The control whose input method you'd like to change /// The input mode you'd like to change to public static void SetInputMode(Control ctrl, InputMode mode) { int GW_CHILD = 5; ushort EM_SETINPUTMODE = 222; //Get the handle for the control ctrl.Capture = true; IntPtr h = GetCapture(); ctrl.Capture = false; //Get the child window for the control IntPtr hWndEditBox = GetWindow(h, GW_CHILD); //Set the input mode SendMessage(hWndEditBox, EM_SETINPUTMODE, 0, (ushort)mode); } } }
Guest alhabibam Posted April 21, 2005 Report Posted April 21, 2005 Thank you alot vman69. This code was very helpful..
Guest vman69 Posted April 21, 2005 Report Posted April 21, 2005 Thank you alot vman69. This code was very helpful.. <{POST_SNAPBACK}> Im glad that the code snippet helps you.
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now