delphi中鼠标滚轮问题

2025-04-06 01:57:11
推荐回答(1个)
回答1:

直接屏蔽了鼠标滚轮操作……

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, ADODB, GridsEh, DBGridEh, StdCtrls, ComCtrls;

type
TForm1 = class(TForm)
DBGridEh1: TDBGridEh;
DataSource1: TDataSource;
ADOTable1: TADOTable;
RichEdit1: TRichEdit;
procedure FormCreate(Sender: TObject);

private
Procedure OnMouseWheel(Var Msg :TMsg;var Handled:Boolean);

public

end;

var
Form1: TForm1;

implementation

Procedure TForm1.OnMouseWheel(Var Msg :TMsg;var Handled:Boolean);
begin
if Msg.message = WM_MouseWheel then
begin
if Msg.wParam = 0 then
begin
if DBGridEh1.Focused then SendMessage(DBGridEh1.Handle,WM_VSCROLL,SB_NONE,0);
end;
Handled:= True;
end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
Application.OnMessage:=OnMouseWheel;
end;

end.