Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

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

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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".


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...