当前位置:主页>Delphi教程>文章内容
给DBGrid添加鼠标滚动事件
来源: 作者: 发布时间:2007-04-29  
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;


 
上一篇:用Delphi编写论坛灌水机   下一篇:列出本机所有的Ip
 
  相关文章
·用Delphi编写论坛灌水机
·列出本机所有的Ip
·PB开发规范.doc
·用delphi批量导入某子目录下所有JPG图
·Delphi程序设计规范
·dbgrideh如何实现点击标题排序
·控制台输出'颜色'字
·delphi制作的托盘程序
·PB与DELPHI的比较
·关于exe文件传递参数方法
·TStringGrid使用(1)
·DELPHI实现摄像头拍照
 
【关闭窗口】
推荐本站资源
最新文章