diff --git a/lcl/dbgrids.pas b/lcl/dbgrids.pas index 9a64532be2..c7dc9cfabb 100644 --- a/lcl/dbgrids.pas +++ b/lcl/dbgrids.pas @@ -493,6 +493,7 @@ type function EditorByStyle(Style: TColumnButtonStyle): TWinControl; override; procedure ResetColWidths; destructor Destroy; override; + function MouseToRecordOffset(const x,y: Integer; out Column: TColumn; out RecordOffset: Integer): TGridZone; property AllowOutboundEvents; property SelectedField: TField read GetCurrentField write SetCurrentField; property SelectedIndex: Integer read GetSelectedIndex write SetSelectedIndex; @@ -3323,6 +3324,31 @@ begin inherited Destroy; end; +function TCustomDBGrid.MouseToRecordOffset(const x, y: Integer; out + Column: TColumn; out RecordOffset: Integer): TGridZone; +var + aCol,aRow: Integer; +begin + Result := MouseToGridZone(x, y); + + Column := nil; + RecordOffset := 0; + + if (Result=gzInvalid) or (Result=gzFixedCells) then + exit; + + MouseToCell(x, y, aCol, aRow); + + if (Result=gzFixedRows) or (Result=gzNormal) then + RecordOffset := aRow - Row; + + if (Result=gzFixedCols) or (Result=gzNormal) then begin + aRow := ColumnIndexFromGridColumn(aCol); + if aRow>=0 then + Column := Columns[aRow]; + end; +end; + { TComponentDataLink } function TComponentDataLink.GetFields(Index: Integer): TField; diff --git a/lcl/grids.pas b/lcl/grids.pas index e31ef8ba13..8b2290aac5 100644 --- a/lcl/grids.pas +++ b/lcl/grids.pas @@ -853,6 +853,7 @@ type procedure AssignTo(Dest: TPersistent); override; procedure AutoAdjustColumn(aCol: Integer); virtual; procedure BeforeMoveSelection(const DCol,DRow: Integer); virtual; + procedure BeginAutoDrag; override; function BoxRect(ALeft,ATop,ARight,ABottom: Longint): TRect; procedure CacheMouseDown(const X,Y:Integer); procedure CalcAutoSizeColumn(const Index: Integer; var AMin,AMax,APriority: Integer); virtual; @@ -7059,6 +7060,17 @@ begin if Assigned(OnBeforeSelection) then OnBeforeSelection(Self, DCol, DRow); end; +procedure TCustomGrid.BeginAutoDrag; +begin + if ((goColSizing in Options) and (Cursor=crHSplit)) or + ((goRowSizing in Options) and (Cursor=crVSplit)) + then + // TODO: Resizing in progress, add an option to forbid resizing + // when DragMode=dmAutomatic + else + BeginDrag(False); +end; + procedure TCustomGrid.CalcAutoSizeColumn(const Index: Integer; var AMin, AMax, APriority: Integer); begin