type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
procedure AppMessage(var msg: TMsg; var handled: boolean);
procedure SetIMEMode(Value : TModes);
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.AppMessage(var msg: TMsg; var handled: boolean);
begin
if (Msg.Message = WM_IME_KEYDOWN) then
begin
SetIMEMode(English); // 한가지 모드로 고정
Dispatch(Msg);
handled := True;
end;
end;
procedure TForm1.SetIMEMode(Value : TModes);
var
TIMC: HIMC;
dwSentence : DWORD;
dwConversion : DWORD;
begin
TIMC := ImmGetContext(Application.Handle);
ImmGetConversionStatus(TIMC, dwConversion, dwSentence);
case Value of
Native : ImmSetConversionStatus(TIMC, IME_CMODE_NATIVE, dwSentence);
English : ImmSetConversionStatus(TIMC, IME_CMODE_ALPHANUMERIC , dwSentence);
end;
ImmReleaseContext(Application.Handle, TIMC);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Application.OnMessage := AppMessage;
end;
아래 예제는 IME 원도우즈 메시지를 처리하며 막는 소스입니다.
예전에 참고했던 소스인데요. 도움이 되실런지...
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Imm;
type
TModes = (Native, English);
type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
procedure AppMessage(var msg: TMsg; var handled: boolean);
procedure SetIMEMode(Value : TModes);
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.AppMessage(var msg: TMsg; var handled: boolean);
begin
if (Msg.Message = WM_IME_KEYDOWN) then
begin
SetIMEMode(English); // 한가지 모드로 고정
Dispatch(Msg);
handled := True;
end;
end;
procedure TForm1.SetIMEMode(Value : TModes);
var
TIMC: HIMC;
dwSentence : DWORD;
dwConversion : DWORD;
begin
TIMC := ImmGetContext(Application.Handle);
ImmGetConversionStatus(TIMC, dwConversion, dwSentence);
case Value of
Native : ImmSetConversionStatus(TIMC, IME_CMODE_NATIVE, dwSentence);
English : ImmSetConversionStatus(TIMC, IME_CMODE_ALPHANUMERIC , dwSentence);
end;
ImmReleaseContext(Application.Handle, TIMC);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Application.OnMessage := AppMessage;
end;
end.