반응형
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, imm, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function GetImeName(const winctr :TWinControl):string;
var
kl: HKL;
Imc: HIMC;
imename: array[0..255]of char;
begin
winctr.SetFocus;
Imc := ImmGetContext(winctr.Handle);
if not ImmGetOpenStatus(Imc)then ImmSetOpenStatus(Imc, TRUE);
Kl := GetKeyboardLayout(0);
if not ImmIsIME(Kl)then result:='' else
ImmGetDescription(Kl,imename, sizeof(imename));
result:= strpas(imename);
ImmReleaseContext(winctr.Handle, Imc);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
ShowMessage(GetImeName(Self));
end;
end.
반응형