Mega Code Archive

 
Categories / Delphi / Hardware
 

Disable MouseScroll in any control

Title: Disable MouseScroll in any control Question: How to Disable MouseScroll in any control in Delphi Answer: {********************************************************** * How to Disable MouseScroll in any control in Delphi * * * Author :Mehdi Mohammadian 28/04/2007 ********************************************************* } { This example is writeen for disable MouseLeave in ListBox Control for other control replace ListBox1 with those control } unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) ListBox1: TListBox; Button1: TButton; procedure FormCreate(Sender: TObject); procedure MyWindowProc(var Message: TMessage); private { Private declarations } public { Public declarations } end; var Form1: TForm1; OldWindowProc: TWndMethod; implementation {$R *.dfm} procedure TForm1.FormCreate(Sender: TObject); begin OldWindowProc:=ListBox1.WindowProc; ListBox1.WindowProc:=MyWindowProc; end; procedure TForm1.MyWindowProc(var Message: TMessage); begin if Message.Msg WM_MOUSEWHEEL then OldWindowProc(Message); // call default ListBox1 WindowProc method to handle all other messages end; end.