[RESOLVED] How to get Unicode char on IME window in VB6?
You just imagine you are doing an Editable Flexgrid or Grid type of UserControl...
I have a Flexgrid. I add a textbox for text input.
Double Click the Cell, the textbox will appear then I can typing my text without any problem. After typing, I press <Enter> key to move focus to next Cell (textbox will turn invisible,the text set to Cell of course) ,then press Alphabetic Key, before textbox1 turn visible, the Alphabetic KeyCode automatically goto invisible textbox,after that,the textbox appear.
The problem is that I lost Unicode if the Alphabetic KeyCode represent Unicode on IME But English and numeric is always OK.
The sequence logic is:
Select a Cell by Mouse --> Press <Alphabetic Key> -->Bring out IME -->IME will appear word combinations ---> I choose the 1st then press <Enter> key --> the TextBox appearing with the word -->Textbox got focus already,I can typing what I want -->Press Enter key to finish typing--->Focus Move to Next Cell ---> Press <Alphabetic Key> ---...
The problem is not vb6 textbox is non-unicode, VB6 textbox fully support Chinese/Japanese/Korean when OS is Chinese/Japanese/Korean
The problem is how to get IME Unicode without using Textbox or RichEdit.
I made a demo for simulation.
1. Select your IME input Language except English, otherwise,IME window doesn't appear. I use Baidu input as IME. You can use MS IME.
2. Click Picture1 to gain focus
3. Typing Alphabetic Key, IME is appearing and IME windows got few word combinations. Choose one.
4. Enter key to transfer text on IME to textbox.
5. The word is suppose go to invisible textbox before visible.
6. After textbox visible, I see my Unicode lost with question mark or weird characters.
Refer to screenshot and demo project.
You also can learn how to pisition IME window.
Code:
Select Case uMsg
Case WM_IME_SETCONTEXT
If Not wParam = 0 Then
Dim flag As Boolean
flag = ImmAssociateContextEx(lng_hWnd, 0, 16)
If flag Then
Dim IntPtr As Long
IntPtr = ImmGetContext(lng_hWnd)
flag = ImmSetOpenStatus(IntPtr, True)
End If
End If
Case WM_IME_STARTCOMPOSITION
Dim hIMC As Long
hIMC = ImmGetContext(lng_hWnd)
Dim cf As COMPOSITIONFORM
cf.dwStyle = 2
cf.ptCurrentPos.X = Picture1.ScaleLeft + 3
cf.ptCurrentPos.Y = Picture1.ScaleTop + Picture1.Height - 16
ImmSetCompositionWindow hIMC, cf
Case WM_IME_CHAR
'Send IME Char to Picture1.KeyPress
Picture1_KeyPress CUIntToInt(wParam And &HFFFF&)
End Select
Last edited by Jonney; Jan 16th, 2015 at 11:43 PM.