治不好的不孕症:DBGrid中失去焦点后输入法改变2

来源:百度文库 编辑:偶看新闻 时间:2024/04/30 16:38:35
使用DBGrideh控件时,每当焦点从此控件转移时,都会自动将输入法关闭,给用户输入数据带来很大的不便,原因就是DBgrideh在处理WM_killFocus时的代码有些小问题。
   把dbgrideh.pas打开后找到下面二个过程,将打星号的语句注释掉就可以彻底解决此问题。
   
procedure TDBGridInplaceEdit.WMKillFocus(var Message: TWMKillFocus);
begin
  if not SysLocale.FarEast then inherited
  else
  begin

*    ImeName := Screen.DefaultIme;//将此句注释掉

    ImeMode := imDontCare;
    inherited;

    //将此IF语句注释掉
*    if HWND(Message.FocusedWnd) <> Grid.Handle then
*      ActivateKeyboardLayout(Screen.DefaultKbLayout, KLF_ACTIVATE);

  end;
  if FListVisible and not
    ((Message.FocusedWnd = FActiveList.Handle) or
    (GetParent(Message.FocusedWnd) = FActiveList.Handle)
    ) then
    CloseUp(False)
  else if MRUList.DroppedDown and not (Message.FocusedWnd = MRUListControl.Handle) then
    MRUListCloseUp(MRUList, False);
//  if (Message.FocusedWnd <> Grid.Handle) then
//    Grid.ControlLeaveFocus;
  if Grid.FSelectionActive <> Grid.IsSelectionActive then
    Grid.SelectionActiveChanged;
end;

//==========
procedure TCustomDBGridEh.WMKillFocus(var Message: TWMKillFocus);
var
  InvalidRect: TRect;
begin
  if FSortMarking and
    not ((InplaceEditor <> nil) and (Message.FocusedWnd = InplaceEditor.Handle)) then
  begin
    FSortMarking := False;
    DoSortMarkingChanged;
  end;

  if HandleAllocated and (dgRowSelect in Options) then
  begin
    with inherited Selection do
      InvalidRect := BoxRect(Left - FrozenCols, Top, Right, Bottom);
    WindowsInvalidateRect(Handle, InvalidRect, False);
  end;

  if not SysLocale.FarEast
    then inherited
  else
  begin
*    ImeName := Screen.DefaultIme;//将此句注释掉
    ImeMode := imDontCare;
    inherited;

//将此If语句注释掉
*    if not ((InplaceEditor <> nil) and (Message.FocusedWnd = InplaceEditor.Handle))
*      then ActivateKeyboardLayout(Screen.DefaultKbLayout, KLF_ACTIVATE);

  end;

//  if not IsMyInplaceControlHandle(HWND(Message.WParam)) then
//    ControlLeaveFocus;
  if FSelectionActive <> IsSelectionActive then
    SelectionActiveChanged;
end