Заменять умляуты во время набора
Оформил: DeeCo
Автор: http://www.swissdelphicenter.ch
{
This code allows you to replaces umlauts (i.e. 'д', 'ц', etc.)
with 'ae', 'oe', etc. while typing.
Mit diesem Code kann man Umlautzeichen (д, ц, ь usw.) durch
ae, oe usw. ersetzen. Dies geschieht applikationsweit, wдhrend der Eingabe.
}
procedure TForm1.AppOnMessage(var Msg: TMsg; var Handled: Boolean);
type
TReplacement = record
chIn: Char;
chOut: string[2]
end;
TReplacements = array [0..6] of TReplacement;
const
Replacements: TReplacements = ((chIn: 'д'; chOut: 'ae'),
(chIn: 'ц'; chOut: 'oe'),
(chIn: 'ь'; chOut: 'ue'),
(chIn: 'Д'; chOut: 'Ae'),
(chIn: 'Ц'; chOut: 'Oe'),
(chIn: 'Ь'; chOut: 'Ue'),
(chIn: 'Я'; chOut: 'ss'));
var
i: Integer;
c: Char;
begin
Handled := False;
if Msg.Message = WM_CHAR then
begin
if Chr(Msg.wParam) in ['д', 'ц', 'ь', 'Д', 'Ц', 'Ь', 'Я'] then
begin
for i := Low(Replacements) to High(Replacements) do
if Chr(Msg.wParam) = Replacements[i].chIn then
begin
Msg.wParam := Ord(Replacements[i].chOut[1]);
with Longrec(Msg.lParam) do
Hi := (Hi and $FF00) or VKKeyScan(Replacements[i].chOut[2]);
PostMessage(Msg.hwnd, WM_CHAR, Ord(Replacements[i].chOut[2]),
Msg.wParam);
with Longrec(Msg.lParam) do
Hi := (Hi and $FF00) or VKKeyScan(Char(Msg.wParam));
Break;
end;
end;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Application.OnMessage := AppOnMessage;
end;
|