Delphi DbGrid鼠标滚屏


本文整理自网络,侵删。

 Delphi的DbGrid默认不支持滚屏。通过一下代码可以让DbGrid支持鼠标滚屏
 
procedure NewGridWnd(var message:TMessage); 
 
OldGridWnd: TWndMethod;


procedure TForm1.FormCreate(Sender: TObject);
begin
  
  //支持鼠标滚动
  OldGridWnd :=dbgrd.WindowProc;
  dbgrd.WindowProc :=NewGridWnd;
end;
//支持鼠标滚动
procedure TForm1.NewGridWnd(var message:TMessage);
var
  IsNeg: Boolean;
begin
  if message.Msg = WM_MOUSEWHEEL then
    begin
      IsNeg :=Short(message.WParamHi)<0;
      if IsNeg then
        dbgrd.DataSource.DataSet.MoveBy(1)
      else
        dbgrd.DataSource.DataSet.MoveBy(-1)
    end
  else
    OldGridWnd(message);
end;

相关阅读 >>

Delphi 实现拦截api的钩子(hook)

Delphi xe6 android 实现base64字符串的解析

Delphi检测用户超过5分钟没有操作键盘或鼠标

Delphi tfdconnection只能取得50处理

Delphi 几种程序自杀的方法

Delphi 动态更改webbrowser数据流内容

Delphi 使用泛型的 tarray 为动态数组排序

Delphi 公历转农历函数

Delphi xe 移动平台 showmodal 范例

Delphi webbrowser1 缩放网页

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...

    正在狠努力加载,请稍候...