Delphi 拦截滚轮事件不响应滚轮的上下滚动
2017-02-15 15:57
471 查看
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls;
type TForm1 = class(TForm)
Panel1: TPanel; ComboBox1: TComboBox; Label1: TLabel; procedure FormCreate(Sender: TObject); private { Private declarations }
Procedure OnMouseWheel(Var Msg: TMsg; var Handled: Boolean);
public { Public declarations }
end;
var Form1: TForm1;
implementation {$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
Application.OnMessage := OnMouseWheel;
end;
procedure TForm1.OnMouseWheel(var Msg: TMsg; var Handled: Boolean);
begin
if Msg.message = WM_MOUSEWHEEL then
if (ActiveControl IS TComboBox) or (ActiveControl IS TStringGrid) then//TComboBox和 TStringGrid不响应滚轮
Handled := True;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
Application.OnMessage := nil;
end;
end.
type TForm1 = class(TForm)
Panel1: TPanel; ComboBox1: TComboBox; Label1: TLabel; procedure FormCreate(Sender: TObject); private { Private declarations }
Procedure OnMouseWheel(Var Msg: TMsg; var Handled: Boolean);
public { Public declarations }
end;
var Form1: TForm1;
implementation {$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
Application.OnMessage := OnMouseWheel;
end;
procedure TForm1.OnMouseWheel(var Msg: TMsg; var Handled: Boolean);
begin
if Msg.message = WM_MOUSEWHEEL then
if (ActiveControl IS TComboBox) or (ActiveControl IS TStringGrid) then//TComboBox和 TStringGrid不响应滚轮
Handled := True;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
Application.OnMessage := nil;
end;
end.
相关文章推荐
- Delphi笔记
- cardinal delphi
- Delphi的线程Demo
- delphi 调用 c++builder
- Delphi使程序的窗口出现在最前面并激活
- Delphi接口的底层实现
- windows server 2008 r2 COM+配置
- delphi 如何判断应用程序未响应
- Delphi基础必记-快捷键
- Delphi 共享内存的应用
- Delphi7 内存管理及 FastMM 研究 (对于EXE和DLL内存共享很有用)
- delphi 实现两个exe文件共享内存映像的代码
- DLL何时需共享内存管理器
- Delphi 中的哈希表(2): TStringHash
- 欢迎使用CSDN-markdown编辑器
- Delphi 中的哈希表(1): THashedStringList
- DELPHI和BCB的版本定义宏全集 VER130 VER140 VER145 VER150
- 解决Delphi ADO无法为更新定位行。一些值可能已在最后一次读取后已更改的问题
- RAD Studio (Delphi) Firemonkey 教程
- delphi 10.1 berlin 开发iOS程序偏好设置(Settings Bundle)