WEB开发网      婵犻潧鍊婚弲顐︽偟椤栨稓闄勯柦妯侯槸閻庤霉濠婂骸浜剧紒杈ㄥ笚閹峰懘鎮╅崹顐ゆ殸婵炴垶鎸撮崑鎾趁归悩鐑橆棄闁搞劌瀛╃粋宥夘敃閿濆柊锕傛煙鐎涙ê鐏f繝濠冨灴閹啴宕熼鍡╀紘婵炲濮惧Λ鍕叏閳哄懎绀夋繛鎴濈-楠炪垽鎮归崶褍妲婚柛銊ュ缁傚秹鏁撻敓锟� ---闂佹寧娲╅幏锟�
开发学院软件开发Delphi 给DBGrid添加鼠标滚动事件 阅读

给DBGrid添加鼠标滚动事件

 2006-02-04 13:55:06 来源:WEB开发网 闂侀潧妫撮幏锟�闂佸憡鍨电换鎰版儍椤掑倵鍋撳☉娆嶄沪缂傚稄鎷�婵犫拃鍛粶闁靛洤娲ㄩ埀顒佺⊕閵囩偟绱為敓锟�闂侀潧妫撮幏锟�  闂佺ǹ绻楀▍鏇㈠极閻愬灚瀚梺鍨儏閳ь剙绉归弻銊р偓闈涙啞閻h京鈧敻鍋婇崰鏍х暦閿燂拷
核心提示:unit Unit1;interfaceusesWindows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, DB, ADODB, Grids, DBGrids;type TForm1 = class(TForm)
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;

Tags:DBGrid 添加 鼠标

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接