Guest Will Posted August 5, 2004 Report Posted August 5, 2004 Thanks to NielC_MVP for his bit a code, i will share here: using System; using System.Windows.Forms; using System.Runtime.InteropServices; namespace MyNamespace { public enum InputMode : ushort { Spell = 0, T9 = 1, Numeric = 2, Text = 3, }; /// <summary> /// Summary description for InputMethod. /// </summary> public class ControlInput { [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); /// <summary> /// Set the input mode for a control that is passed. /// </summary> /// <param name="ctrl">The control whose input method you'd like to change</param> /// <param name="mode">The input mode you'd like to change to</param> 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); } } }[/code]
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now