//第1种方法
procedure TForm1.FormMouseWheel(Sender: TObject; Shift: TShiftState;
WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
begin
if ActiveControl = ComboBox1 then
Handled := True;
end;
//第2种方法(了解该方法后,以后会有助于我们处理更复杂的问题)
unit Unit1; interface uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls; type
TForm1 = class(TForm)
cbb1: TComboBox;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
FOldWndProc: TWndMethod;
public
{ Public declarations }
procedure NewWndProc(var Message: TMessage);
end; var
Form1: TForm1; implementation {$R *.dfm} procedure TForm1.NewWndProc(var Message: TMessage);
begin
if ((Message.Msg <> WM_MOUSEWHEEL) ) then
FOldWndProc(Message);
end; procedure TForm1.FormCreate(Sender: TObject);
begin
FOldWndProc := cbb1.WindowProc;
cbb1.WindowProc := NewWndProc; end; procedure TForm1.FormDestroy(Sender: TObject);
begin
cbb1.WindowProc := FOldWndProc;
end;
delphi combobox屏蔽鼠标滑动-LMLPHP
04-26 10:07