disable automatic changing of keyboard layout in DbGrids.pas in VCL

末鹿安然 提交于 2019-11-28 08:25:09

问题


I use ActivateKeyboardLayout(HKL_NEXT, KLF_ACTIVATE); to load Persian keyboard layout using Delphi XE2, But sometimes I click on TextBox or DbGrid control the keyboard automatically is changed to English layout.

How can I disable automatic changing of keyboard layout?


回答1:


We have same issues. This bug appeared after upgrade from D2006 to D2010.

Issue is in 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 have no idea why Borland/Embarcadero added "if block" after inherited. Change causes switching keyboard layout back to default. We had to copy DBGrids to our projects and remove "if block".



来源:https://stackoverflow.com/questions/9756357/disable-automatic-changing-of-keyboard-layout-in-dbgrids-pas-in-vcl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!