Filter(disabling) mouse wheel messages in a VisualCLX Form

247 views Asked by At

I have inherited a Delphi 7 (VisualCLX) application to maintain and I want to filter some windows message like the mouse wheel (WM_MOUSEWHEEL) on the main form(TForm) of the application, is it possible on the Visual CLX ? How ?

I know that is possible on the VCL, but I'm looking for some solutions on the old Cross-Platform (CLX) ...

Note

I need to disable the mousewheel event because it keeps changing the active page(TPageControl) and this is very annoying in Delphi with Component Library for Cross-Platform (CLX), so any other workaround that solve the problem is welcome ...

1

There are 1 answers

0
David Heffernan On BEST ANSWER

Filtering input messages in CLX is not simple. There appears to be nothing like the VCL's OnMessage.

You can stop mouse wheel events being handled by CLX page controls with a simple interposer. Add this code to your main form, before the declaration of your main form class.

type
  TPageControl = class(QComCtrls.TPageControl)
  protected
    function DoMouseWheel(Shift: TShiftState; WheelDelta: Integer; 
      const MousePos: TPoint): Boolean; override;
  end;

And then in the implementation section of the unit, add this:

function TPageControl.DoMouseWheel(Shift: TShiftState; WheelDelta: Integer; 
  const MousePos: TPoint): Boolean;
begin
  Result := True;
end;

If you have a number of page controls on different forms then you should declare the interposer in a unit that can be shared by all the forms in your app. Or maybe even derive a proper grown-up sub-class.