Public Class Form1 Private 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 Class Window Inherits NativeWindow 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) 'Console.WriteLine(m.ToString()) 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) Console.WriteLine(buf.ToString(0, l \ 2)) End If End If MyBase.WndProc(m) End Sub End Class End Class