给DBGrid添加鼠标滚动事件
2012-03-22 11:02
246 查看
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;
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;
相关文章推荐
- 给DBGrid添加鼠标滚动事件
- 给DBGrid添加鼠标滚动事件
- 给DBGrid添加鼠标滚动事件
- 给DBGrid添加鼠标滚动事件
- dbgrid鼠标滚动事件
- delphi中的DBGRid鼠标滚动事件
- JQuery实例入门(添加鼠标事件)
- 鼠标滚动一次window.onscroll事件的函数在firfox与Ie中执行的次数不同问题的处理s
- 向Arcglobe中添加MouseWheel事件,使其具有鼠标放大缩小功能。
- AS3中Bitmap为什么不能添加鼠标事件
- 使用jTopo给Html5 Canva中绘制的元素添加鼠标事件_html5教程技巧
- javascript 鼠标滚动事件绑定事件的方法与注意事项
- js鼠标滑轮滚动事件绑定(兼容主流浏览器)
- [MFC] 对话框添加鼠标事件响应
- 为GridView添加鼠标事件
- 给DataGrid添加序号、导航键、鼠标划过事件、删除确认框
- 给DataGrid添加序号、导航键、鼠标划过事件、删除确认框(转)
- 移动端touch事件影响click事件以及在touchmove添加preventDefault导致页面无法滚动的解决方法
- html 5中的鼠标滚动事件
- C# 中手动添加Mousewheel鼠标滚轮事件