VB 6.0中 VScroll怎样相应鼠标滚轮的事件?
答案:1 悬赏:70 手机版
解决时间 2021-11-09 07:41
- 提问者网友:遮云壑
- 2021-11-08 14:43
VB 6.0中 VScroll怎样相应鼠标滚轮的事件?
最佳答案
- 五星知识达人网友:持酒劝斜阳
- 2021-11-08 15:13
it1;
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.追问能解释一下吗?我在form中加了滚动条,但它只能用鼠标点击时方可相应,如何让他相应鼠标滚轮的事件呢?
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.追问能解释一下吗?我在form中加了滚动条,但它只能用鼠标点击时方可相应,如何让他相应鼠标滚轮的事件呢?
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯