Disable the mouse wheel (Views: 2141)
Problem/Question/Abstract: Is there any way to disable the mouse wheel for a particular application or form? Answer: You can use a handler for the Application.OnMessage event to filter out messages (e.g WM_MOUSEWHEEL) before any control in your application sees them. Note that this will not work with all mouse drivers. There are some that can be configured to not post the standard wheel messages but to send WM_VSCROLL messages instead if the control under the mouse has scrollbars. This "compatibility mode" is there to make the wheel usable with applications that do not have wheel support build in. procedure TMainForm.FormCreate(Sender: TObject); begin Application.OnMessage := AppMessage; end; procedure TMainform.Appmessage(var Msg: TMsg; var Handled: Boolean); begin Handled := msg.Message = WM_MOUSEWHEEL; end; If you only want to do this for a specific form class you would modify this method to procedure TMainform.Appmessage(var Msg: TMsg; var Handled: Boolean); begin Handled := (msg.Message = WM_MOUSEWHEEL) and (Screen.Activeform is TMySpecialFormclass); end; |