Recent

Author Topic: How to Mousewheel capture in Tumbviewer?  (Read 1172 times)

barsoom

  • Jr. Member
  • **
  • Posts: 51
How to Mousewheel capture in Tumbviewer?
« on: June 23, 2020, 01:44:04 am »
Thumbcontrol.pas unit handle the keys up, down right, left and enter keys, however, not the mousewheel.
How can i do the selected picture move up/down in the vertical layout of thumviewer when using the mousewheel?
Thanks.

wp

  • Hero Member
  • *****
  • Posts: 11855
Re: How to Mousewheel capture in Tumbviewer?
« Reply #1 on: June 24, 2020, 12:16:01 am »
In which package is this ThumbControl?

barsoom

  • Jr. Member
  • **
  • Posts: 51
Re: How to Mousewheel capture in Tumbviewer?
« Reply #2 on: June 25, 2020, 08:34:52 pm »
Thumbviewer

https://github.com/theo222/lazarus-thumbviewer

I have a Thumbcontrol component in the main form with a vertical layout. What i need is to move up or down the scroll by using the mousewheel, as it occurs whwn uning the up and down keys of the keyboard.
« Last Edit: June 25, 2020, 10:03:41 pm by barsoom »

furious programming

  • Hero Member
  • *****
  • Posts: 852
Re: How to Mousewheel capture in Tumbviewer?
« Reply #3 on: June 26, 2020, 04:13:29 am »
Just add the WMMouseWheel and WMMouseHWheel message handlers and in them call the method responsible for scrolling the component using the keys.

Code: Pascal  [Select][+][-]
  1. procedure WMMouseWheel(var Message: TLMMouseEvent); message LM_MOUSEWHEEL;
  2. procedure WMMouseHWheel(var Message: TLMMouseEvent); message LM_MOUSEHWHEEL;

Check what the Messsage argument has, recognize horizontal/vertical direction and, on the basis of recognized direction, pass the appropriate key constant (in the form of variable) to the KeyDown method. Or simply modify the component code (without inheritance), copy the parts of the logic from the KeyDown method to the message handlers and that's it.

I don't know this component, I've never seen or used it, but it should work fine.
« Last Edit: June 26, 2020, 05:57:18 pm by furious programming »
Lazarus 3.2 with FPC 3.2.2, Windows 10 — all 64-bit

Working solo on an acrade, action/adventure game in retro style (pixelart), programming the engine and shell from scratch, using Free Pascal and SDL. Release planned in 2026.

 

TinyPortal © 2005-2018