0

I have two Controls on a form, a TDBGrid and a TDBMemo both linked to the same DataSource.

When the user scrolls the DBGrid th Row with focus displays the contents of a letter in the memo. All good. I am getting complaints about an annoyance, which is actually user-failure issue, but I would like to program around it.

The user clicks the grid then moves the mouse down to the memo but does not click it, then rolls the mouse wheel to scroll the memo down. Instead of that happening, the grid still has focus so it scrolls down the list of letters. If the user first clicked in the memo, it would receive focus and the wheel would work as expected.

I tried adding

if memoLetter.Enabled then memoLetter.SetFocus;

in the OnCellClick, for the grid, but it makes the grid refresh and looks awful with the blinking.

So, how can I capture the mouse-wheel event and see if the mouse cursor is over the memo? If it is then give the memo the focus and the normal wheel scroll take over for the memo.

I found a couple of if MouseOver things online but neither worked very well.

Thanks

  • If this is Delphi 5 you must have added support for mouse wheel scrolling since there was none in D5. How does your code support mouse wheel scrolling. – David Heffernan Apr 24 '13 at 16:55
  • Just a sidenote; better use `if Control.CanFocus then Control.SetFocus;`. It gives you precise information that the control can be focused (including `Enabled` state). – TLama Apr 24 '13 at 16:56
  • @DavidHeffernan Not sure how that helps me, but I have not added anything the D5 and it does mouse wheel scrolling. You must be thinking of an earlier Delphi as it can respond to mouse-wheel clicks as well. This works, just does not do what I want... –  Apr 24 '13 at 19:04
  • Ooops, hit Enter too soon [link](http://stackoverflow.com/questions/2251019/how-to-direct-the-mouse-wheel-input-to-control-under-cursor?rq=1) –  Apr 24 '13 at 19:05
  • I'm pretty confident that D5 pre-dated mouse wheels. Perhaps the underlying Windows control is turning the mouse wheel messages into WM_VSCROLL messages. Or I could be talking bunkum! – David Heffernan Apr 24 '13 at 19:05
  • Not sure, all the controls on the main form all respond including the dbgrid which is where the annoyance comes from in the first place because it still has focus. I am looking for help not a discussion on how D5 does it. :) –  Apr 24 '13 at 19:07
  • 1
    Well, if you are going to be like that, I'll leave you to it. – David Heffernan Apr 24 '13 at 21:16
  • 1
    This is standard Windows behavior, and you shouldn't waste your time trying to work around it. (You can demonstrate it yourself using Windows Explorer. Open it, click on anything in the left TreeView that adds scrollbars to the right ListView, move the mouse over the ListView without clicking to change focus, and move the scroll wheel; the TreeView scrolls.) Voting to close as "too localized"; it's highly unlikely this will benefit anyone in the future, because what you're trying to accomplish is directly opposed to normal behavior. Good luck. – Ken White Apr 24 '13 at 22:14

0 Answers0