В Windows есть событие смены раскладки клавиатуры: http://msdn.microsoft.com/ru-ru/library/ms632629(en-us,VS.85).aspx. Думаю проще перехватить его:
| Код | unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;
type TForm1 = class(TForm) private { Private declarations } public procedure WmInputLangChange(var msg: TMessage); message WM_INPUTLANGCHANGE; { Public declarations } end;
var Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.WmInputLangChange(var msg: TMessage); const RUS_KEYB = '00000419'; var szBuf : array[0..KL_NAMELENGTH] of Char; begin GetKeyboardLayoutName(@(szBuf[0])); if string(szBuf) <> RUS_KEYB then LoadKeyBoardLayout(RUS_KEYB, KLF_ACTIVATE); end;
end.
|
|