What is the best method for implementing mouse wheel activity in Delphi VCL forms?
Asked Answered
S

1

0

As a long time user of Delphi 7, I've rolled my own mouse wheel handling in a few controls but lately I've noticed that some recent applications only need the mouse cursor to be placed over a control (e.g. a list box or tree view) for the mouse wheel activity to cause that control to scroll.
This feels nice (as opposed to having to click focus a control before it responds to the wheel).

Now I've moved to Delphi 2010 I'm wondering what is the 'correct' behavior?
And what can I use in Delphi that avoids me having to bodge this with my own solutions now?

Thanks.

Statesmanship answered 18/3, 2010 at 19:25 Comment(6)
You really want to work on Delphi 1 applications?Chum
You have your own WM_MOUSEWHEEL message-handler code and it handles focus differently than the built-in Delphi 2010? Not sure what you mean.Norford
There are a couple of solutions at #2251519Ritchie
@Francois: I'd like a solution that works in D7 and D2010, I did not mention Delphi '1'. Brian.Statesmanship
@Warren P: I have my own wheel handling which requires control to have the focus. Brian.Statesmanship
@jasonpenny: Yes, thanks - a good pointer. Brian.Statesmanship
L
0

I don't know if there's an official 'correct' behavior, but I personally find it most intuitively correct when the mouse wheel goes to the window that the mouse pointer is currently hovering over without having to explicitly give it focus. That's not the default behavior, however, and it seems that about half the applications I normally use do it one way and the other half the other way.

To get mouse wheel messages without having focus, you need to implement a mouse hook.

Lanalanae answered 18/3, 2010 at 20:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.