In Delphi, how to intercept the KeyPress Event like a WideChar instead of Char? It ignores all keys above 255 and return wrong values.
I´m also with problem with TJvInspector, how to edit Strings like WideStrings intead of regular Strings with it?
In Delphi, how to intercept the KeyPress Event like a WideChar instead of Char? It ignores all keys above 255 and return wrong values.
I´m also with problem with TJvInspector, how to edit Strings like WideStrings intead of regular Strings with it?
Cezar Wagenheimer from Green Sauce Games
Programmer of Druids - Battle of Magic, Abra Academy, Abra Academy - Returning Cast, Rabbit Jump, Dreams of a Geisha and Heroes from the Past: Joan of Arc
Wagenheimer's Game Development Blog
Use something like this:
Code:// this function is from "TntSystem.pas" fron TNT Unicode controls. function KeyUnicode(CharCode: Word): WideChar; var AChar: AnsiChar; begin if CharCode <= Word(High(AnsiChar)) then begin AChar := AnsiChar(CharCode); MultiByteToWideChar(KeyboardCodePage, MB_USEGLYPHCHARS, @AChar, 1, @Result, 1); end else Result := WideChar(CharCode); end; procedure TForm1.FormCreate(Sender: TObject); begin Application.OnMessage:= MyMessage; end; procedure TForm1.MyMessage(var Msg: TMsg; var Handled: Boolean); var WideCh: WideChar; begin if (Msg.message = WM_CHAR) then begin WideCh:= KeyUnicode(Msg.wParam); // Use WideCh for some purpose end; end;
Hi Lefepower!
Thanks for the answer, but something is not working yet!
I did try to use the Japanese あ (12354 Unicode) code Letter... But the Msg.wParam is getting 41090 then i did type this letter! I did try anothers japanese letters, and all is getting higher than 41000 codes. If i did type the letter on a TntEdit component, by example, and get it¬¥s code using the KeyUnicode funciton, all is fine (it returns 12354). The problem is with Application Message i think, in the Msg.Wparam.
Have you some idea of what is the problem?
Cezar Wagenheimer from Green Sauce Games
Programmer of Druids - Battle of Magic, Abra Academy, Abra Academy - Returning Cast, Rabbit Jump, Dreams of a Geisha and Heroes from the Past: Joan of Arc
Wagenheimer's Game Development Blog
Look what strange!
If i did put a TNTEDIT and a TEDIT on my Form!
If i¬¥m inside the TNTEDIT control, Msg.wParam is returning 12354 for あ, if i¬¥m inside the TEDIT control, Msg.wParam is returning 41090 for あ.
Why this behavior? Does what change when i inside an TNTEDIT Control that Msg.wParam now works, should i set this to works in my whole application?
Cezar Wagenheimer from Green Sauce Games
Programmer of Druids - Battle of Magic, Abra Academy, Abra Academy - Returning Cast, Rabbit Jump, Dreams of a Geisha and Heroes from the Past: Joan of Arc
Wagenheimer's Game Development Blog
Hi Lifepower!!
I still have no success in getting the real Unicode Japanese Unicode Keycodess to pass to my GUI SYSTEM in Asphyre System!
I did try your suggestion, and everything that is in this discussion!
http://tinyurl.com/5g68ye
Did you get any sucess with Japanese Input in your Game?
I can sucefully Display Japanese Text in my Edit Controls, i can Read and Save Japanese Text in it, i can COPY and PAST Japanese text to it, but i still can´t write Japanese directelly to it because of this!
How does Ime works It can pass more than an caracter at time?
I can suceffuly intercept the correct Msg.wParam in WM_IME_COMPOSITION...
In all others WM_ , noone is called when i type Japanese letters.
But the problem is that in WM_IME_COMPOSITION the Letter in not Ready
yet.... i´m totally lost.... i´m using IME in Windows Vista, and it shows
and Editor when i start typing in Ime Mode.. How it works in a Real Japanese
Operating System with a Real Japanese Keyboard? When i type something, it send a WM_IME_COMPOSITION, but
sometimes it changes the letter in editor, and it always send the first
letter on "Ime Editor" when the editor is ON, and not the letter that actually typing...
Somebody have some advices of how to use this?
Cezar Wagenheimer from Green Sauce Games
Programmer of Druids - Battle of Magic, Abra Academy, Abra Academy - Returning Cast, Rabbit Jump, Dreams of a Geisha and Heroes from the Past: Joan of Arc
Wagenheimer's Game Development Blog
According to Platform SDK:
The code I posted worked for me to introduce Russian, French and Spanish unicode characters in the game simultaneously. I haven't checked IME nor Japanese input.An application that processes keyboard input typically ignores all but the WM_CHAR and WM_UNICHAR messages, passing any other messages to the DefWindowProc function. Note that WM_CHAR uses 16-bit Unicode Transformation Format (UTF) while WM_UNICHAR uses UTF-32. The system uses the WM_SYSCHAR and WM_SYSDEADCHAR messages to implement menu mnemonics.
The difference in final values that you have detected might have something to do with characters having different codes in unicode table, or possibly endian issues (why don't you print values in hex?)If i¬¥m inside the TNTEDIT control, Msg.wParam is returning 12354 for あ, if i¬¥m inside the TEDIT control, Msg.wParam is returning 41090 for あ.
Also, TNTEdit might have translated character into UTF-32, while in TEdit you may be receiving UTF-16 characters.
Bookmarks