Quote Originally Posted by DrUnicode View Post
It was 9 years ago when I ran into this issue reported by a customer.
Apparently a particular IME generated a surrogate pair, 2 Unicode characters for a single keystroke.
In this case you don't get a WM_KEYDOWN for the second charcter but you do get another WM_CHAR.
We need to find out which IME does this and which keystroke to test this.
Ok, then following way would solve it. (Though I cannot test)
Code:
    Case WM_CHAR
        Static SurrogateKeyChar As Integer
        Dim KeyChar As Integer, UniChar As String
        If TextBoxKeyCodeCache <> 0 Then
            If TextBoxDeadKeyCodeCache <> 0 Then
                KeyCodeToUnicode TextBoxDeadKeyCodeCache, TextBoxDeadScanCodeCache, TextBoxDeadKeyStateCache()
                TextBoxDeadKeyCodeCache = 0
            End If
            Dim KeyState(0 To 255) As Byte
            GetKeyboardState KeyState(0)
            UniChar = KeyCodeToUnicode(TextBoxKeyCodeCache, HiWord(lParam), KeyState())
            TextBoxKeyCodeCache = 0
        End If
        If Len(UniChar) > 0 Then
            KeyChar = CUIntToInt(AscW(UniChar))
            If Len(UniChar) > 1 Then SurrogateKeyChar = CUIntToInt(AscW(Mid$(UniChar, 2, 1)))
        Else
            If SurrogateKeyChar <> 0 Then
                KeyChar = SurrogateKeyChar
                SurrogateKeyChar = 0
            Else
                KeyChar = CUIntToInt(wParam And &HFFFF&)
            End If
        End If
        RaiseEvent KeyPress(KeyChar)