Solved

Disable Mouse Wheel

Posted on 2004-10-20
6
379 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
Independent Software Vendors: 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!

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

710 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