Solved

Disable Mouse Wheel

Posted on 2004-10-20
6
381 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses
Course of the Month6 days, 18 hours left to enroll

623 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