LCL, dbgrid scrolling was locked under some circunstances, fix issue #9381

git-svn-id: trunk@11741 -
This commit is contained in:
jesus 2007-08-04 23:38:29 +00:00
parent 84abb757e2
commit 9c18feacc6

View File

@ -79,7 +79,7 @@ type
); );
TDbGridExtraOptions = set of TDbGridExtraOption; TDbGridExtraOptions = set of TDbGridExtraOption;
TDbGridStatusItem = (gsVisibleMove, gsUpdatingData, gsAddingAutoColumns, TDbGridStatusItem = (gsUpdatingData, gsAddingAutoColumns,
gsRemovingAutoColumns); gsRemovingAutoColumns);
TDbGridStatus = set of TDbGridStatusItem; TDbGridStatus = set of TDbGridStatusItem;
@ -175,7 +175,6 @@ type
procedure FocusControl(Field: TFieldRef); override; procedure FocusControl(Field: TFieldRef); override;
// Testing Events // Testing Events
procedure CheckBrowseMode; override; procedure CheckBrowseMode; override;
function CheckFirstRecord: boolean;
procedure EditingChanged; override; procedure EditingChanged; override;
procedure UpdateData; override; procedure UpdateData; override;
function MoveBy(Distance: Integer): Integer; override; function MoveBy(Distance: Integer): Integer; override;
@ -829,13 +828,8 @@ begin
if aDataSet=nil then DebugLn('nil)') if aDataSet=nil then DebugLn('nil)')
else DebugLn(aDataSet.Name,')'); else DebugLn(aDataSet.Name,')');
{$endif} {$endif}
if not (gsVisibleMove in FGridStatus) or FDatalink.CheckFirstRecord then LayoutChanged;
LayoutChanged
else
UpdateScrollBarRange;
UpdateActive; UpdateActive;
//RestoreEditor;
end; end;
procedure TCustomDBGrid.OnDataSetOpen(aDataSet: TDataSet); procedure TCustomDBGrid.OnDataSetOpen(aDataSet: TDataSet);
@ -923,11 +917,10 @@ begin
if Distance<>0 then begin if Distance<>0 then begin
Row:= FixedRows + FDataLink.ActiveRecord; Row:= FixedRows + FDataLink.ActiveRecord;
Invalidate Invalidate;
end else end else
UpdateActive; UpdateActive;
if OldEditorMode and (dgAlwaysShowEditor in Options) then if OldEditorMode and (dgAlwaysShowEditor in Options) then
EditorMode := True; EditorMode := True;
end; end;
@ -1798,15 +1791,6 @@ var
FDatalink.MoveBy(Amount); FDatalink.MoveBy(Amount);
{$IfDef dbgGrid}DebugLn('KeyDown.DoMoveBy FIN');{$Endif} {$IfDef dbgGrid}DebugLn('KeyDown.DoMoveBy FIN');{$Endif}
end; end;
procedure DoMoveBySmall(amount: Integer);
begin
{$IfDef dbgGrid}DebugLn('KeyDown.DoMoveBySmall(',IntToStr(Amount),')');{$Endif}
Include(FGridStatus, gsVisibleMove);
FDatalink.CheckFirstRecord;
FDatalink.MoveBy(Amount);
Exclude(FGridStatus, gsVisibleMove);
{$IfDef dbgGrid}DebugLn('KeyDown.doMoveBySmall FIN');{$Endif}
end;
procedure DoCancel; procedure DoCancel;
begin begin
{$IfDef dbgGrid}DebugLn('KeyDown.doCancel INIT');{$Endif} {$IfDef dbgGrid}DebugLn('KeyDown.doCancel INIT');{$Endif}
@ -1846,7 +1830,7 @@ var
end; end;
end else begin end else begin
result:=false; result:=false;
doMoveBySmall(1); doMoveBy(1);
if GridCanModify and FDataLink.EOF then begin if GridCanModify and FDataLink.EOF then begin
doAppend; doAppend;
end; end;
@ -1859,7 +1843,7 @@ var
if InsertCancelable then if InsertCancelable then
doCancel doCancel
else else
doMoveBySmall(-1); doMoveBy(-1);
result := FDatalink.DataSet.BOF; result := FDatalink.DataSet.BOF;
{$ifdef dbgGrid}DebugLn('DoVKUP FIN');{$endif} {$ifdef dbgGrid}DebugLn('DoVKUP FIN');{$endif}
end; end;
@ -2033,9 +2017,7 @@ var
procedure doMoveBy; procedure doMoveBy;
begin begin
{$IfDef dbgGrid} DebugLn('DBGrid.MouseDown MoveBy INIT'); {$Endif} {$IfDef dbgGrid} DebugLn('DBGrid.MouseDown MoveBy INIT'); {$Endif}
Include(FGridStatus, gsVisibleMove);
FDatalink.MoveBy(P.Y - Row); FDatalink.MoveBy(P.Y - Row);
Exclude(FGridStatus, gsVisibleMove);
{$IfDef dbgGrid} DebugLn('DBGrid.MouseDown MoveBy END'); {$Endif} {$IfDef dbgGrid} DebugLn('DBGrid.MouseDown MoveBy END'); {$Endif}
end; end;
procedure doMoveToColumn; procedure doMoveToColumn;
@ -2283,9 +2265,7 @@ begin
if Assigned(OnMouseWheelDown) then if Assigned(OnMouseWheelDown) then
OnMouseWheelDown(Self, Shift, MousePos, Result); OnMouseWheelDown(Self, Shift, MousePos, Result);
if not Result and FDatalink.Active then begin if not Result and FDatalink.Active then begin
Include(FGridStatus, gsVisibleMove);
FDatalink.MoveBy(1); FDatalink.MoveBy(1);
Exclude(FGridStatus, gsVisibleMove);
Result := True; Result := True;
end; end;
end; end;
@ -2297,9 +2277,7 @@ begin
if Assigned(OnMouseWheelUp) then if Assigned(OnMouseWheelUp) then
OnMouseWheelUp(Self, Shift, MousePos, Result); OnMouseWheelUp(Self, Shift, MousePos, Result);
if not Result and FDatalink.Active then begin if not Result and FDatalink.Active then begin
Include(FGridStatus, gsVisibleMove);
FDatalink.MoveBy(-1); FDatalink.MoveBy(-1);
Exclude(FGridStatus, gsVisibleMove);
Result := True; Result := True;
end; end;
end; end;
@ -2918,12 +2896,6 @@ begin
inherited CheckBrowseMode; inherited CheckBrowseMode;
end; end;
function TComponentDataLink.CheckFirstRecord: boolean;
begin
Result := FOldFirstRecord<>FirstRecord;
FOldFirstRecord := FirstRecord;
end;
procedure TComponentDataLink.EditingChanged; procedure TComponentDataLink.EditingChanged;
begin begin
{$ifdef dbgDBGrid} {$ifdef dbgDBGrid}