1

I have several keyboards and they type in different TMemos. In english, everything works fine, but in Korean the keystrokes get sent to the IME before it sends it to my onKeypress (which handles/identifies the different keyboards), so I can't exactly tell which keyboard it came from before that.

I don't exactly know how to use WinApi, but I need to learn to use the part that deals with the IME. There is a lot of information HERE, but I need to know how to apply it in delphi. I need to store each users keystrokes and send them to the IME.

Perhaps someone can help me learn to use IMM.PAS

Community
  • 1
  • 1
Dian
  • 1,187
  • 3
  • 18
  • 35
  • What task do you want to accomplish? – Alex Jun 24 '10 at 08:24
  • To (possibly) store my keystrokes and send them to the IME. Or whatever works so that the keystrokes from different keyboards do not interfere with one another. – Dian Jun 24 '10 at 08:39
  • trying to use two physical keyboards with one computer, or trying to support language-switching inside your application? – Warren P Jun 25 '10 at 14:22
  • trying to separate the input that I'm receiving from the IME. – Dian Jun 26 '10 at 07:03

2 Answers2

3

Got it to work. Using ImmGetContext, ImmSetCompositon, ImmGetComposition and NormalizeString.

procedure TForm1.IMEFUNCTION(var msg: TMsg);
var
  buf: array [0..20] of char;
  hHimc: HIMC;
  i, j: integer;
  str: string;
  temporary: PWideChar;
begin

   hHimc:= ImmGetContext (msg.hwnd);
   if hHimc = 0 then
    Exit;
   fillchar (buf, 20, 0);
   ImmSetCompositionStringW (hHimc, SCS_SETSTR, PChar (''), Length(''), nil, 0);
   ImmGetCompositionString (hHimc, GCS_COMPSTR, @buf, 20);

  temporary:= PWideChar(Edit1.Text+buf[0]);
  NormalizeString(5 , temporary, -1, buf, 20);
  Edit1.Text:=buf;

    end;//end if
  end;//end for
  ImmReleaseContext (handle, hHimc);

end;

Side note: I didn't really use TEdit, I used a StringGrid and a for-loop. (but the general idea is there)

Dian
  • 1,187
  • 3
  • 18
  • 35
0

I doubt that Windows supports what you want to do, and I doubt that you can make Windows work differently. It sounds like you are trying to use two physical keyboards on a single computer.

IMM.PAS is a wrapper for the Windows IME API, and does not appear to have been written to help you do exactly what you want to do.

Why aren't you using two computers, with two keyboards?

Warren P
  • 65,725
  • 40
  • 181
  • 316
  • It's part of the specifications my company gave me. I've succeeded in separating the keystrokes/characters that I've received from the IME but I now I can't get the characters that need multiple keystrokes. I was wondering if possibly the other functions I haven't tried out can solve this like the one with the RECONVERTSTRING, but there is not that much delphi sample codes which help me figure out how to use the functions. – Dian Jun 26 '10 at 07:09