Hola.
Me quede pensando que agregando un detalle te puede servir para más de un
TDBGrid en el mismo form:
Código Delphi
[-]
private
procedure MMouseEvent(var Msg: TMsg; var Handled: Boolean);
end;
....
procedure TForm1.FormCreate(Sender: TObject);
begin
Application.OnMessage := MMouseEvent;
end;
procedure TForm1.MMouseEvent(var Msg: TMsg; var Handled: Boolean);
var
P: TPoint;
WControl: TWinControl;
G: TDBGrid;
i: Integer;
begin
WControl:= FindVCLWindow(Mouse.CursorPos);
if Assigned(WControl) and (WControl is TDBGrid) then
begin
G:= TDBGRid(WControl);
P:= ScreenToClient(Mouse.CursorPos);
if P.X = G.Left + GetSystemMetrics(SM_CXVSCROLL) then
for i:= G.Columns.Count-1 downto G.SelectedIndex do
SendMessage(G.Handle, WM_HSCROLL, SB_LINELEFT, 0);
if P.X = G.Left + G.Width - GetSystemMetrics(SM_CXVSCROLL) then
for i:= G.SelectedIndex to G.Columns.Count-1 do
SendMessage(G.Handle, WM_HSCROLL, SB_LINERIGHT, 0);
end
end;
Saludos.