Recent

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

barsoom

  • New Member
  • *
  • Posts: 22
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: 7529
Re: How to Mousewheel capture in Tumbviewer?
« Reply #1 on: June 24, 2020, 12:16:01 am »
In which package is this ThumbControl?
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

barsoom

  • New Member
  • *
  • Posts: 22
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

  • Sr. Member
  • ****
  • Posts: 467
  • I click a little.
    • TreeStructInfo — format for text and binary configuration files
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 2.0.10 with FPC 3.2.0 (SVN Revision 63526), Windows XP (all 32-bit)

 

TinyPortal © 2005-2018