Recent

Author Topic: Mouse Wheel in StringGrid  (Read 13553 times)

faber

  • Guest
Mouse Wheel in StringGrid
« on: February 23, 2009, 08:29:10 pm »
I want to set up MouseWheel behavior in the same way as the vertical ScrollBar (with out goScrollKeepVisible).
I don't want to change the location of active cell by mouse wheel.
I just want to move the entire sheet when I'm scrolling by mouse(like MS Office).
How to do that ?

faber

  • Guest
Re: Mouse Wheel in StringGrid
« Reply #1 on: March 03, 2009, 09:54:58 am »
I found solution by overriding the DoMouseWheelDown and DoMouseWheelUp routines

cpalx

  • Hero Member
  • *****
  • Posts: 753
Re: Mouse Wheel in StringGrid
« Reply #2 on: March 03, 2009, 06:57:14 pm »
i dont get it...

faber

  • Guest
Re: Mouse Wheel in StringGrid
« Reply #3 on: March 03, 2009, 07:03:33 pm »
i dont get it...
?
By override DoMouseWheel... ( off, Result:=false ) I get what I want.

noctrex

  • New Member
  • *
  • Posts: 22
Re: Mouse Wheel in StringGrid
« Reply #4 on: July 13, 2012, 12:01:56 pm »
I found solution by overriding the DoMouseWheelDown and DoMouseWheelUp routines
I know this post is old, but is it possible to tell us how you did it?
I'm currently struggling with this...
Lazarus-1.1-37420-fpc-2.6.1-20120526-win32

User137

  • Hero Member
  • *****
  • Posts: 1791
    • Nxpascal home
Re: Mouse Wheel in StringGrid
« Reply #5 on: July 13, 2012, 01:06:39 pm »
I tried this quickly, at least it compiles:

Code: [Select]
  TStringGrid2 = class(TStringGrid)
  protected
    function DoMouseWheel(Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint): Boolean; override;
  end;

// ...

function TStringGrid2.DoMouseWheel(Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint): Boolean;
begin
  //Result:=inherited DoMouseWheel(Shift, WheelDelta, MousePos);
  Result:=false;
end;

To insert a TStringGrid2 on form, you need to do a little more tricks. You can:
- Make it a new component.
- TStringGrid2.Create and set its properties manually.
- Draw a TStringGrid on form, and then change it to TStringGrid2. You may have to manually edit .lfm file.

Bernd82

  • New Member
  • *
  • Posts: 30
Re: Mouse Wheel in StringGrid
« Reply #6 on: August 15, 2017, 01:10:36 pm »
There is a new(?) property: MouseWheelOption. Set it to mwGrid. Works fine!

Graeme

  • Hero Member
  • *****
  • Posts: 1428
    • Graeme on the web
Re: Mouse Wheel in StringGrid
« Reply #7 on: August 25, 2017, 01:18:49 am »
There is a new(?) property: MouseWheelOption. Set it to mwGrid. Works fine!
Awesome, thanks for sharing. I worked recently on a LCL project and was fighting with this exact issue.
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

zbyna

  • Jr. Member
  • **
  • Posts: 63
Re: Mouse Wheel in StringGrid
« Reply #8 on: September 01, 2017, 12:23:39 am »
There is a new(?) property: MouseWheelOption. Set it to mwGrid. Works fine!
Unfortunately does not work in TDBGrid.

RayoGlauco

  • Full Member
  • ***
  • Posts: 176
  • Beers: 1567
Re: Mouse Wheel in StringGrid
« Reply #9 on: March 26, 2018, 10:42:57 am »
There is a new(?) property: MouseWheelOption. Set it to mwGrid. Works fine!

Great!! I spent many time figuring out how to do this!!
To err is human, but to really mess things up, you need a computer.

 

TinyPortal © 2005-2018