unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, ADODB, GridsEh, DBGridEh;
type
TMyGrid=class(TDBGridEh)
procedure OnMouseWheel(var Message: TWMMOUSEWHEEL); message WM_MOUSEWHEEL;
end;
TForm1 = class(TForm)
ADOConnection1: TADOConnection;
ADODataSet1: TADODataSet;
DataSource1: TDataSource;
procedure FormCreate(Sender: TObject);
private
DBGridEh1: TMyGrid;
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{ TMyGrid }
procedure TMyGrid.OnMouseWheel(var Message: TWMMOUSEWHEEL);
begin
if Message.Msg = WM_MouseWheel then
begin
if Message.WheelDelta > 0 then
begin
if Focused then
begin
showmessage('鼠标上滚');
end;
end
else
begin
if Focused then
begin
showmessage('鼠标下滚');
end;
end;
inherited;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
DBGridEh1:= TMyGrid.Create(self);
DBGridEh1.Parent:=self;
DBGridEh1.DataSource:=DataSource1;
DBGridEh1.Align:=alclient;
end;
end.