[Lazarus] TLabel inside a TScrollBox (under Win32) MouseWheel issue

Sandro Cumerlato sandro.cumerlato at gmail.com
Tue Jul 15 19:43:32 CEST 2014


Reference: "[Lazarus] Scrollbox and mousewheel"
http://lists.lazarus.freepascal.org/pipermail/lazarus/2012-July/074650.html


Hello everybody,
I'm writing to you about an issue discovered while using a TLabel
inside a TScrollBox (under Win32).

The problem is that the TLabel hides the MouseWheel action of the
TScrollBox if the mouse is over the TLabel.

To solve this problem I've exposed the Label1.OnMouseWheel property to
call the following ScrollBox1.OnMouseWheel event:

procedure TFormMain.SrollBox1MouseWheel(Sender: TObject; Shift: TShiftState;
  WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
begin
  with SrollBoxRight.VertScrollBar do
    Position := Position - Sign(WheelDelta) * Increment;
  Handled := true;
end;


The attached patch exposes the TLabel.OnMouseWheel event to solve the
TLabel/TScrollBox MouseWheel issue.

For the same reason, IMHO, other GUI controls that can be inserted
into a TScrollBox should expose OnMouseWheel event.


Thank you for reading!

Sandro Cumerlato
-------------- next part --------------
Index: /freepascal/laz/1.3/lcl/stdctrls.pp
===================================================================
--- /freepascal/laz/1.3/lcl/stdctrls.pp	(revisione 45865)
+++ /freepascal/laz/1.3/lcl/stdctrls.pp	(copia locale)
@@ -1502,6 +1502,7 @@
     property OnMouseUp;
     property OnMouseEnter;
     property OnMouseLeave;
+    property OnMouseWheel;
     property OnChangeBounds;
     property OnContextPopup;
     property OnResize;


More information about the Lazarus mailing list