Reputation: 859
I use ActivateKeyboardLayout(HKL_NEXT, KLF_ACTIVATE);
to load a Persian keyboard layout using Delphi XE2, but sometimes when I click on a TextBox or DbGrid control, the keyboard automatically is changed to English layout.
How can I disable automatic changing of keyboard layout?
Upvotes: 5
Views: 2253
Reputation: 2558
We have the same issues. This bug appeared after the upgrade from D2006 to D2010.
The issue is in file DBGrids.pas:
procedure TCustomDBGrid.WMKillFocus(var Message: TMessage);
begin
ImeName := Screen.DefaultIme;
ImeMode := imDontCare;
inherited;
if not ((InplaceEditor <> nil) and
(HWND(Message.WParam) = InplaceEditor.Handle)) then
ActivateKeyboardLayout(Screen.DefaultKbLayout, KLF_ACTIVATE);
end;
I don't have any idea why Borland/Embarcadero added the "if block" after inherited. The change causes switching keyboard layout back to the default. We had to copy DBGrids to our projects and remove the "if block".
Upvotes: 5