Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 388
  • Last Modified:

Disable Mouse Wheel

Is there a way of disabling the usage of the mousewheel throughout my program?
0
Narusegawa
Asked:
Narusegawa
  • 3
  • 2
1 Solution
 
Wim ten BrinkCommented:
Just capture the mouse-wheel event at application level. It is the WM_MOUSEWHEEL message that you have to ignore...
0
 
NarusegawaAuthor Commented:
Okay. Sounds simple enough. How do I go about capturing it? If you don't mind.
0
 
Wim ten BrinkCommented:
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
Ivanov_GCommented:
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
 
Wim ten BrinkCommented:
@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
 
Ivanov_GCommented:
Workshop_Alex, yep, I agree with you. :))
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now