Recent

Author Topic: How to capture horizontal mouse scroll event?  (Read 19514 times)

jamie

  • Hero Member
  • *****
  • Posts: 6090
Re: How to capture horizontal mouse scroll event?
« Reply #30 on: December 15, 2018, 05:44:33 pm »
If you don't already have one make a Debugger hook for the messages

Use SetWindowsHookEx and specify Mouse messages as the hook..

have these messages ported to a list of a limited size of course with wrap around and have the
time posted on the messages. Have the code stop accumulating when it receives both messages in the list so that you
can then examine the contents.

 I just did a test here on two different mice and one seems to post to the que of both directions while the
other seems to post only once per event, something to do with the driver.

 I have in my old Delphi pc a unit I wrote that can be included in projects for doing window hooking and message logging.

The only true wisdom is knowing you know nothing

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: How to capture horizontal mouse scroll event?
« Reply #31 on: December 15, 2018, 06:24:45 pm »
EDIT: Regarding the desire to limit the redraws, some of my users load very large high resolution images.
Are you redrawing the whole image?

jamie

  • Hero Member
  • *****
  • Posts: 6090
Re: How to capture horizontal mouse scroll event?
« Reply #32 on: December 15, 2018, 07:12:52 pm »
 When I do such things I keep the master in the background and a viewable for the canvas..

 This makes it so you only draw just the portion of what you want to view, even if have compressed
version of the original with Half Tone blending..
The only true wisdom is knowing you know nothing

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: How to capture horizontal mouse scroll event?
« Reply #33 on: December 15, 2018, 09:00:31 pm »
If you don't already have one make a Debugger hook for the messages

Use SetWindowsHookEx and specify Mouse messages as the hook..

have these messages ported to a list of a limited size of course with wrap around and have the
time posted on the messages. Have the code stop accumulating when it receives both messages in the list so that you
can then examine the contents.

 I just did a test here on two different mice and one seems to post to the que of both directions while the
other seems to post only once per event, something to do with the driver.

 I have in my old Delphi pc a unit I wrote that can be included in projects for doing window hooking and message logging.

Very cool!

So when the second (other) mouse posts once per event, do the events occur in any particular order? That is first a vert, then a horz, or is it unpredictable?
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.2
macOS 12.1: Lazarus 2.2.6 (64 bit Cocoa M1)
Ubuntu 18.04.3: Lazarus 2.2.6 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.2.6 (64 bit on VBox)

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: How to capture horizontal mouse scroll event?
« Reply #34 on: December 15, 2018, 09:14:11 pm »
Are you redrawing the whole image?

When I do such things I keep the master in the background and a viewable for the canvas..

 This makes it so you only draw just the portion of what you want to view, even if have compressed
version of the original with Half Tone blending..

No, I don't redraw the whole image, I use a buffer and (the terrific) BGRABitmap to just draw what needs to be drawn as the image is zoomed and panned. It is actually pretty efficient, so my earlier comment on the size of the image is not so relevant. I wrote the code years ago, and kind of forgot when I made the comment. Still, cutting the redraws in half when scrolling would be nice.
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.2
macOS 12.1: Lazarus 2.2.6 (64 bit Cocoa M1)
Ubuntu 18.04.3: Lazarus 2.2.6 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.2.6 (64 bit on VBox)

jamie

  • Hero Member
  • *****
  • Posts: 6090
Re: How to capture horizontal mouse scroll event?
« Reply #35 on: December 15, 2018, 10:05:40 pm »
depending on what your app is you may want to look into using GL/DX to show image to screen... much faster...

getting back to the mouse messages, the H and V messages do not have any order, it's what ever got detected first..

From what I am seeing it's the difference in OS or mouse driver as to how its handled.

I'll get back to this later, got a couple of ions in the fire at the moment..

The only true wisdom is knowing you know nothing

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: How to capture horizontal mouse scroll event?
« Reply #36 on: December 15, 2018, 10:45:52 pm »
depending on what your app is you may want to look into using GL/DX to show image to screen... much faster...

getting back to the mouse messages, the H and V messages do not have any order, it's what ever got detected first..

From what I am seeing it's the difference in OS or mouse driver as to how its handled.

I'll get back to this later, got a couple of ions in the fire at the moment..

Thanks jamie. Good to know about the H and V messages, it kind of shoots a hole in my idea. Maybe that makes creating an event for both at one difficult. I'll just handle them as they come then, it works good enough that way.

I don't know if I need the muscle of GL/DX, but will be curious to hear your ideas. I've thought about GL, but it looked like a steep learning curve. No hurry at all on my end, this is a relatively minor issue that I was tinkering with.
« Last Edit: December 15, 2018, 10:47:38 pm by VTwin »
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.2
macOS 12.1: Lazarus 2.2.6 (64 bit Cocoa M1)
Ubuntu 18.04.3: Lazarus 2.2.6 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.2.6 (64 bit on VBox)

jamie

  • Hero Member
  • *****
  • Posts: 6090
Re: How to capture horizontal mouse scroll event?
« Reply #37 on: December 15, 2018, 10:53:07 pm »
Just a note, if you set your brush.color := bcNone or Brush.Style := bsClear; that should prevent the background
erase when updating screen during the onpaint event.
 
You could also possible handle the WM_EraseBkGrd message and redirect it but I've found using the brush trick
works better...

 Also, by doing this, if you have un painted areas, you can place a clip rectangle there and do a background paint...
The only true wisdom is knowing you know nothing

 

TinyPortal © 2005-2018