Public Class Form1 Private WithEvents win As Window Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load win = New Window() win.AssignHandle(TextBox1.Handle) End Sub Private Sub TextBox1_TextChanged(ByVal sender As Object, ByVal e As EventArgs) Handles TextBox1.TextChanged Label1.Text = TextBox1.Text End Sub Private Sub win_Typing(ByVal text As String) Handles win.Typing Label2.Text = text End Sub Private Class Window Inherits NativeWindow Public Event Typing(ByVal text As String) Private Declare Function ImmGetContext Lib "imm32" (ByVal hWnd As IntPtr) As IntPtr Private Declare Auto Function ImmGetCompositionString Lib "imm32" _ (ByVal hIMC As IntPtr, _ ByVal dwIndex As Integer, _ ByVal lpBuf As System.Text.StringBuilder, _ ByVal dwBufLen As Integer) As Integer Private Declare Function ImmReleaseContext Lib "imm32.dll" _ (ByVal hWnd As IntPtr, ByVal hIMC As IntPtr) As Integer Protected Overrides Sub WndProc(ByRef m As Message) Const WM_IME_COMPOSITION As Integer = &H10F Const GCS_COMPSTR As Integer = 8 If m.Msg = WM_IME_COMPOSITION Then If (m.LParam.ToInt32() And GCS_COMPSTR) <> 0 Then Dim imc As IntPtr = ImmGetContext(Handle) Dim length As Integer = ImmGetCompositionString(imc, GCS_COMPSTR, Nothing, 0) Dim buf As New System.Text.StringBuilder(length) Dim l As Integer = ImmGetCompositionString(imc, GCS_COMPSTR, buf, length) ImmReleaseContext(Handle, imc) RaiseEvent Typing(buf.ToString(0, l \ 2)) End If End If MyBase.WndProc(m) End Sub End Class End Class