суббота, 30 июля 2016 г.

Кривой скроллинг в TAdvStringGrid 2.8

Компонент TAdvStringGrid версии 2.8 (про другие не знаю) не совсем корректно обрабатывает прокрутку таблицы. Так, если начать скроллинг в другом компоненте и там достигнуть конца прокрутки, то скроллинг "возвращается" в AdvStringGrid, даже если мышка не над этим компонентом. Поэтому лезем в исходник и добавляем такой код:
{$IFDEF DELPHI5_LVL}
function TAdvStringGrid.DoMouseWheelDown(Shift: TShiftState;
  MousePos: TPoint): Boolean;
var
  lc: Integer;
  p: TPoint;
begin
  GetCursorPos(p);
  if (not PtInRect(ClientRect, ScreenToClient(p))) then begin
    Result := false; exit; end; //Sleep(1);
  if (goRowSelect in Options) and Navigation.KeepHorizScroll then
  begin
    StartUpdate;
    lc := LeftCol;
    Result := inherited DoMouseWheelDown(Shift,MousePos);
    LeftCol := lc;
    ResetUpdate;
  end
  else
    Result := inherited DoMouseWheelDown(Shift,MousePos);
end;

function TAdvStringGrid.DoMouseWheelUp(Shift: TShiftState;
  MousePos: TPoint): Boolean;
var
  lc: Integer;
  p: TPoint;
begin
  GetCursorPos(p);
  if (not PtInRect(ClientRect, ScreenToClient(p))) then begin
    Result := false; exit; end; //Sleep(1);
  if (goRowSelect in Options) and Navigation.KeepHorizScroll then
  begin
    StartUpdate;
    lc := LeftCol;
    Result := inherited DoMouseWheelUp(Shift,MousePos);
    LeftCol := lc;
    ResetUpdate;
  end
  else
  begin
    if (Row < RowCount) and (Col < ColCount) then
      Result := inherited DoMouseWheelUp(Shift,MousePos)
    else
      Result := True;
  end;
end;
{$ENDIF}


Комментариев нет: