Recent

Author Topic: OnMouseWheel event in dbgrid  (Read 10394 times)

JanRoza

  • Hero Member
  • *****
  • Posts: 672
    • http://www.silentwings.nl
OnMouseWheel event in dbgrid
« on: May 18, 2007, 04:29:35 pm »
In my application which has a dbgrid (based on a dbf table) I show the current record number and total number of records in the stausbar.
As long as I use the keyboard to scroll through the dbgrid everything works fine and if I click on a cell with the mouse the correct info is shown as well but nothing happens when I scroll using the mouse wheel.
Any chance dbgrid will get a OnMousewheel event (like in Delphi) in the near future?
Or is there another way to tackle this?
(I'm using Lazarus 0.9.23 on Windows Vista)

Thanks for looking into this.
Jan Roza
OS: Windows 10 (64 bit) / Linux Mint (64 bit)
       Lazarus 3.2 FPC 3.2.2
       CodeTyphon 8.40 FPC 3.3.1

jesusr

  • Sr. Member
  • ****
  • Posts: 484
RE: OnMouseWheel event in dbgrid
« Reply #1 on: May 18, 2007, 06:45:59 pm »
What events do you use to detect that something has changed?

JanRoza

  • Hero Member
  • *****
  • Posts: 672
    • http://www.silentwings.nl
OnMouseWheel event in dbgrid
« Reply #2 on: May 18, 2007, 09:36:33 pm »
I don't, the grid is readonly and only meant to browse through a table.
To the right of the grid the content of the selected record is shown in dbedit fields so there is no need for editing in the dbgrid itself.

All I'm looking for is a means to keep the current record number updated while scrolling through the dbgrid using the mouse wheel.
I like a challenge but I'm stuck with this one.
OS: Windows 10 (64 bit) / Linux Mint (64 bit)
       Lazarus 3.2 FPC 3.2.2
       CodeTyphon 8.40 FPC 3.3.1

jesusr

  • Sr. Member
  • ****
  • Posts: 484
OnMouseWheel event in dbgrid
« Reply #3 on: May 18, 2007, 10:04:15 pm »
does using the mousewheel have any effect in the grid?

JanRoza

  • Hero Member
  • *****
  • Posts: 672
    • http://www.silentwings.nl
OnMouseWheel event in dbgrid
« Reply #4 on: May 19, 2007, 01:21:51 am »
Oh yes it has, rolling the wheel makes the selector scrolling up and down the grid nicely and the details of the record under the selector bar are shown in the dbedit fields on the right.
For now I manage the current record number via OnkeyUp, OnMouseMove and OnMouseUp but those events don't cover scrolling via the mouse wheel.
OS: Windows 10 (64 bit) / Linux Mint (64 bit)
       Lazarus 3.2 FPC 3.2.2
       CodeTyphon 8.40 FPC 3.3.1

jesusr

  • Sr. Member
  • ****
  • Posts: 484
OnMouseWheel event in dbgrid
« Reply #5 on: May 19, 2007, 04:36:56 am »
I think you better use datasource.OnDataChange event to detect when the active record has changed, because if you later put a dbnavigator for example neither of OnKeyUp, OnMouseDown, OnMouseUp or OnMouseWheel will help you.

JanRoza

  • Hero Member
  • *****
  • Posts: 672
    • http://www.silentwings.nl
OnMouseWheel event in dbgrid
« Reply #6 on: May 19, 2007, 05:15:54 pm »
Thanks JesusR!
That's what I was looking for but missed it.
Your'e absolutely right your way is much better, I'll try it out as soon as I'm home again.
 :D
Jan
OS: Windows 10 (64 bit) / Linux Mint (64 bit)
       Lazarus 3.2 FPC 3.2.2
       CodeTyphon 8.40 FPC 3.3.1

JanRoza

  • Hero Member
  • *****
  • Posts: 672
    • http://www.silentwings.nl
OnMouseWheel event in dbgrid
« Reply #7 on: May 20, 2007, 11:37:57 pm »
:D
Yep, that datasource.OnDataChange suggestion was the solution I needed.
Works like a charm, so many thanks for pointing me in the right direction.

 :D
Jan
OS: Windows 10 (64 bit) / Linux Mint (64 bit)
       Lazarus 3.2 FPC 3.2.2
       CodeTyphon 8.40 FPC 3.3.1

 

TinyPortal © 2005-2018