Solved

Disable Mouse Wheel

Posted on 2004-10-20
6
376 Views
Last Modified: 2010-04-04
Is there a way of disabling the usage of the mousewheel throughout my program?
0
Comment
Question by:Narusegawa
  • 3
  • 2
6 Comments
 
LVL 17

Expert Comment

by:Wim ten Brink
ID: 12356201
Just capture the mouse-wheel event at application level. It is the WM_MOUSEWHEEL message that you have to ignore...
0
 

Author Comment

by:Narusegawa
ID: 12356208
Okay. Sounds simple enough. How do I go about capturing it? If you don't mind.
0
 
LVL 17

Accepted Solution

by:
Wim ten Brink earned 125 total points
ID: 12356488
There are many options. For application-wide solutions you could try to use to set an event handler for Application.OnMessage using either TApplicationEvents or by assigning the event in runtime.

The code itself is "Extremely complex"... :-)

procedure TForm1.FormCreate(Sender: TObject);
begin
  // Not needed if you use TApplicationEvents on your form.
  Application.OnMessage := ApplicationEventsMessage;
end;

procedure TForm1.ApplicationEventsMessage( var Msg: tagMSG; var Handled: Boolean );
begin
  if ( Msg.message = WM_MOUSEWHEEL ) then Handled := True;
end;
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 12

Expert Comment

by:Ivanov_G
ID: 12356822
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs;

type
  TForm1 = class(TForm)
  private
    procedure OnMouseWheelMsg (var Msg: TWMMouseWheel); message WM_MOUSEWHEEL;
  public
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.OnMouseWheelMsg(var Msg: TWMMouseWheel);
begin
  Msg.Result := 0;
  Exit;
end;

end.
0
 
LVL 17

Expert Comment

by:Wim ten Brink
ID: 12356932
@Ivanov_G, I've tried something similar like that but it will only stop the form itself from responding to mousehweel messages. However, controls on the form might have their own messagehandlers that will respond to this event, which the form won't capture for them...

And the exit at the end of your function is a bit useless. You're already exiting the function on the next line.
0
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 12357044
Workshop_Alex, yep, I agree with you. :))
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
code issue 8 130
Why can't I create any project with my delphi EXE file? 6 26
Convert MS Word document to a PDF file 9 82
Delphi: sending SMS on android platform 1 21
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question