Simple scrolling Delphi dbgrid

I am making an application that contains orders and prints invoices. I have several tags, edits, tmemos, buttons, data source, adotable, popupmenu and dbgrid in my form.

When I create a program and scroll down the dbgrid scroll bar, it scrolls after releasing the mouse button. But I want a continuous scroll.

Hi

+5
source share
2 answers

This is called thumb tracking. Derive a new class to override scroll behavior. An example of using an interpolator class:

type
  TDBGrid = class(DBGrids.TDBGrid)
  private
    procedure WmVScroll(var Message: TWMVScroll); message WM_VSCROLL;
  end;

  TForm1 = class(TForm)
    DBGrid1: TDBGrid;
    ..

implementation

procedure TDBGrid.WmVScroll(var Message: TWMVScroll);
begin
  if Message.ScrollCode = SB_THUMBTRACK then
    Message.ScrollCode := SB_THUMBPOSITION;
  inherited;
end;


WindowProc , . , , WM_VSCROLL. , .

+9

, Sertac Akyuz, TDBGrid:

  private
    FOrgDBGridWndProc: TWndMethod;
    procedure DBGridWndProc(var Msg: TMessage);
  // ...
  end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  FOrgDBGridWndProc:= DBGrid1.WindowProc;
  DBGrid1.WindowProc := DBGridWndProc;
end;

procedure TForm1.DBGridWndProc(var Msg: TMessage);
begin
  if (Msg.Msg = WM_VSCROLL) and
    (LongRec(Msg.wParam).Lo = SB_THUMBTRACK) then
  begin
      LongRec(Msg.wParam).Lo := SB_THUMBPOSITION;
  end;
  if Assigned(FOrgDBGridWndProc) then
    FOrgDBGridWndProc(Msg);
end;
+2

All Articles