Problem porting app in delphi that used form onmousewheel lazarus / 31-LCL ---------------------------------------------------------------------- snorkel · 2013-03-07 17:12 Hi, I have a app in delphi that uses the forms onmousewheel, now a Lazarus form also has this event, but it behaves differently. On delphi if you drop a panel on the form and set it to align client the forms onmousewheel event will still fire, but on Lazarus it does not. Is there any way to work around this issue? I am using windows 7 by the way, the rest is in my sig. Thanks, ---------------------------------------------------------------------- itmitica · 2013-03-07 20:37 Use TApplicationProperties' OnUserInput event. Here's a sample project: https://github.com/itmitica/lazarus-522-mouse-wheel -- Mitică ---------------------------------------------------------------------- snorkel · 2013-03-07 21:21 Hi, I had already tried that, but the problem is I don't have access to the wheel delta using that method. I didn't see anyway to tell what way the user was moving the mouse wheel. In Delphi because the forms onmousewheel gets all the mouse wheel input you can use it to to scroll a tscrollbox that has a lot of controls on it that steal the mousewheel focus. i.e. procedure Tdataframe.FormMouseWheel(Sender: TObject; Shift: TShiftState;   WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);  var    msg: Cardinal;   code: Cardinal;   i, n: Integer; begin    if sbox = nil then       exit;    if not sbox.Focused then exit;      Handled := true;      If ssShift In Shift Then         msg := WM_HSCROLL             Else                 msg := WM_VSCROLL;      If WheelDelta > 0 Then         code := SB_LINEUP              Else                  code := SB_LINEDOWN;      n:= Mouse.WheelScrollLines;      For i:= 1 to n Do          sbox.Perform( msg, code, 0 );      sbox.Perform( msg, SB_ENDSCROLL, 0 ); end; ---------------------------------------------------------------------- itmitica · 2013-03-07 21:36 Add the OnMouseWheel to TPanel. Right click the TPanel, open the extctrls.pp unit, add the OnMouseWheel properties, recompile Lazarus, use OnMouseWheel events for the new TPanel. http://postimage.org/image/f8d2nar3p/ -- Mitică ---------------------------------------------------------------------- JuhaManninen · 2013-03-07 23:00 Quote from: itmitica on March 07, 2013, 10:36:15 pmAdd the OnMouseWheel to TPanel. Better to use TScrollBox instead of TPanel. Juha ---------------------------------------------------------------------- itmitica · 2013-03-07 23:21 Quote from: JuhaManninen on March 08, 2013, 12:00:01 amBetter to use TScrollBox instead of TPanel. By default, some components, like TEdit, get in the way of form scrolling, on Win at least. So I was showcasing how to make possible the mouse wheel event for components like TEdit or TPanel, components that block the form scroll on mouse wheel. I was not attempting a botched up TPanel for TScrollBox. What's explicitly missing but heavily implied in my post is the appearance of the OnMouseWheel event for the TPanel component, and the possibility to assign a FormMouseWheel method to it. -- Mitică ---------------------------------------------------------------------- snorkel · 2013-03-07 23:21 I tried tscrollbox and it has the same problem, when I embedd stuff in it I want to scroll like edit or label controls they steal the focus from the scroll box and it won't scroll with the mouse wheel. In Delphi I got around that by using the forms onmousewheel, so it would scroll no matter what control was in the tscrollbox. ---------------------------------------------------------------------- itmitica · 2013-03-07 23:31 Quote from: snorkel on March 08, 2013, 12:21:36 amI tried tscrollbox and it has the same problem, when I embedd stuff in it I want to scroll like edit or label controls they steal the focus from the scroll box and it won't scroll with the mouse wheel. Yes, because TEdit or TLabel don't have the OnMouseWheel event, but I gave you the solution. Right click the TEdit or TLabel component, add the three properties OnMouseWheel, OnMouseWheelUp, OnMouseWheelDown. Recompile Lazarus. You now have the OnMouseWheel event for TEdit and you can assign FormMouseWheel method to it, so it will scroll even when the pointer sits over a TEdit or TLabel. -- Mitică ---------------------------------------------------------------------- itmitica · 2013-03-07 23:46 This is a screen cap: http://postimage.org/image/40lcjlyff/ On the left TEdit has no OnMouseWheel events. After the modding of stdctrls.pp and after Lazarus rebuild, TEdit now has a OnMouseWheel event. Just assign to it the TForm1.FormMouseWheel(Sender: TObject; Shift: TShiftState;   WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean) method for the OnMouseWheel form's event. It will now scroll the form even if the pointer is over TEdit components. I would post a complete example, but I won't help much, since the whole deal is the modified stdctrls.pp file and the "forked" Lazarus. Only in the binary you'll be able to test the difference. Let me know if you want me to provide one. -- Mitică ---------------------------------------------------------------------- itmitica · 2013-03-08 00:15 Here is a link to a Win binary: http://ge.tt/1wCfEPa/v/0?c It's just a form and two TEdits, the first one with the AutoSize set to false. You can mouse wheel scroll just fine over them. -- Mitică