Guest deBruineBeren Posted December 29, 2005 Report Posted December 29, 2005 (edited) I'm changing the Input modus for use in a textbox to numbers. But when entering number they appear underlined. Just like you are using T9. The maxlengt of the textbox is not working correct as well. Strange thing is that when I go to a textbox where the input modus is set to Spell and then return to the textbox where the input modes is set to number everything is working fine. No underlined numbers and the maxlenght of the textbox is working too. I see a lot of question about input modes on the internet, and everybody seems happy when using this code. Does nobody have this problem ? The code i'm using: Imports System.Runtime.InteropServices --------------------------------------------------------------------------------------------------------- Public Class Form1 ' Interop declarations Private Shared Function GetCapture() As IntPtr End Function Private Shared Function GetWindow(ByVal hWnd As IntPtr, _ ByVal uCmd As Integer) As IntPtr End Function Private Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal msg As UInt16, _ ByVal wParam As UInt16, ByVal lParam As UInt16) As UInt16 End Function ' Input mode enumeration Public Enum InputMode Spell = 0 T9 = 1 Numbers = 2 Text = 3 End Enum --------------------------------------------------------------------------------------------------------- Public Shared Sub SetInputMode(ByVal ctrl As Control, _ ByVal mode As InputMode) Dim GW_CHILD As Integer = 5 Dim EM_SETINPUTMODE As UInt16 = UInt16.Parse(222) ' Get the handle for the current control ctrl.Capture = True Dim h As IntPtr = GetCapture() ctrl.Capture = False ' Get the child window for the control Dim hEditbox As IntPtr = GetWindow(h, GW_CHILD) ' Set the input mode SendMessage(hEditbox, EM_SETINPUTMODE, _ UInt16.Parse(0), _ UInt16.Parse(mode)) End Sub Private Sub txtLatGraden_GetFocus(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtLatGraden.GotFocus SetInputMode(txtLatGraden, InputMode.Numbers) End Sub Private Sub txtLongGraden_GetFocus(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtLongGraden.GotFocus SetInputMode(txtLongGraden, InputMode.Numbers) End Sub Private Sub txtWPName_GetFocus(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtWPName.GotFocus SetInputMode(txtWPName, InputMode.Spell) End Sub --------------------------------------------------------------------------------------------------------- Edited December 29, 2005 by deBruineBeren
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now