Scrollowanie myszka? Co to ma oznaczać przewijanie kółkiem czy ScrollBarem? Jeżeli przewijanie kółkiem to masz przecież MouseWheelUp/Down a jak ScroolBarem to trzeba sobie takie zdarzenie dorobić np:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids;
type
TOnVScrollEvent = procedure(Sender: TObject; ScrollUp: Boolean) of object;
TStringGrid = class(Grids.TStringGrid)
private
fOnVScrollEvent: TOnVScrollEvent;
fOldScrollPos, fNewScrollPos: Integer;
protected
procedure WndProc(var Message: TMessage); override;
public
property OnVScroll: TOnVScrollEvent read fOnVScrollEvent write
fOnVScrollEvent default nil;
constructor Create(AOwner: TComponent); override;
end;
TForm1 = class(TForm)
StringGrid1: TStringGrid;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
procedure OnStringGridVScroll(Sender: TObject; ScrollUp: Boolean);
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
constructor TStringGrid.Create(AOwner: TComponent);
begin
inherited;
fOldScrollPos:= GetScrollPos(Handle, SB_VERT);
end;
procedure TStringGrid.WndProc(var Message: TMessage);
begin
case Message.Msg of
WM_VSCROLL:
begin
fNewScrollPos:= GetScrollPos(Handle, SB_VERT);
if Assigned(fOnVScrollEvent) then
fOnVScrollEvent(Self, fNewScrollPos < fOldScrollPos);
fOldScrollPos:= fNewScrollPos;
end;
end;
inherited;
end;
procedure TForm1.OnStringGridVScroll(Sender: TObject; ScrollUp: Boolean);
const
SCROLL_INFO_FRMT = 'Scroll UP: %s Top Row: %d';
BOOL_STR: array [Boolean] of string = ('False', 'True');
begin
Caption:= Format(SCROLL_INFO_FRMT, [BOOL_STR[ScrollUp],
TStringGrid(Sender).TopRow]);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
StringGrid1.OnVScroll:= OnStringGridVScroll;
end;
end.
EDIT: Nie wiem o co chodzi z tą prędkością i dodawaniem wierszy wiec może coś bliżej wyjaśnisz.