给DBGrid添加鼠标滚动事件
2004-11-17 15:18
393 查看
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, DB, ADODB, Grids, DBGrids;
type
TForm1 = class(TForm)
DBGrid1: TDBGrid;
ADOTable1: TADOTable;
DataSource1: TDataSource;
procedure FormCreate(Sender: TObject);
private
Procedure OnMouseWheel(Var Msg :TMsg;var Handled:Boolean);
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
//------------------------------------------------------------------------------
Procedure TForm1.OnMouseWheel(Var Msg :TMsg;var Handled:Boolean);
begin
if Msg.message = WM_MouseWheel then
begin
if Msg.wParam > 0 then
begin
if DBGrid1.Focused then
SendMessage(DBGrid1.Handle,WM_VSCROLL,SB_PAGEUP,0);
end
else
begin
if DBGrid1.Focused then
SendMessage(DBGrid1.Handle,WM_VSCROLL,SB_PAGEDOWN,0);
end;
Handled:= True;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Application.OnMessage:=OnMouseWheel; // 截获鼠标滚动事件
end;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, DB, ADODB, Grids, DBGrids;
type
TForm1 = class(TForm)
DBGrid1: TDBGrid;
ADOTable1: TADOTable;
DataSource1: TDataSource;
procedure FormCreate(Sender: TObject);
private
Procedure OnMouseWheel(Var Msg :TMsg;var Handled:Boolean);
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
//------------------------------------------------------------------------------
Procedure TForm1.OnMouseWheel(Var Msg :TMsg;var Handled:Boolean);
begin
if Msg.message = WM_MouseWheel then
begin
if Msg.wParam > 0 then
begin
if DBGrid1.Focused then
SendMessage(DBGrid1.Handle,WM_VSCROLL,SB_PAGEUP,0);
end
else
begin
if DBGrid1.Focused then
SendMessage(DBGrid1.Handle,WM_VSCROLL,SB_PAGEDOWN,0);
end;
Handled:= True;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Application.OnMessage:=OnMouseWheel; // 截获鼠标滚动事件
end;
相关文章推荐
- Windows Powershell创建对象
- 千年零一虫
- 用Ole Automation实现Delphi和AutoCad之间的数据交换
- ATL实现Connection Point的一种简单的方法
- 独具量身定做特色的管理软件--数据大师
- delphi中的时间操作技术(2)
- 路由器网络接口解析
- DirectX.Capture
- Ghost V8.0 使用详解
- 越过调试这道槛——ASP.NET无法调试问题剖析
- 移植到 Windows 2000 和 COM+
- 使用C#开发COM+组件
- 纯编码实现数据库的建立或压缩
- 从数据库中动态选取下拉列表的方法
- 用ASP备份数据库
- 解决打过震荡波补丁之后oracle无法正常启动的问题
- 关于win2000安装的2个问题
- 统一部署 PowerShell 5.1