It is currently Sat Dec 07, 2019 8:10 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 35 posts ]  Go to page Previous  1, 2, 3
Author Message
 Post subject: Re: Keyboard shortcuts for mouse wheel
PostPosted: Tue Nov 19, 2019 10:30 am 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 13, 2010 3:45 pm
Posts: 940
@Lord

If you don't want to understand, I can't help you either. But if you write an application that uses the scroll wheel and you want to share it with others, be fair and include the following warning to your app:

"Attention, this application is not suitable for a mouse with a high resolution mouse wheel."

_________________
sorry for my bad english


Top
 Profile  
Reply with quote  
 Post subject: Re: Keyboard shortcuts for mouse wheel
PostPosted: Wed Nov 20, 2019 2:23 pm 
Offline
Enthusiast
Enthusiast

Joined: Tue May 26, 2009 2:11 pm
Posts: 619
Josh wrote:
...
If you don't want to understand, I can't help you either. But if you write an application that uses the scroll wheel and you want to share it with others, be fair and include the following warning to your app:

"Attention, this application is not suitable for a mouse with a high resolution mouse wheel."
There's no need for this.

You don't always need to know what resolution your mouse has.
Sometimes it is just only neccessary to know witch direction is wanted:
Code:
EnableExplicit

Structure Datas
  WW.i
  WH.i
  ScrollbarV.Point
  ScrollbarVW.i
  ScrollbarVH.i
  ScrollbarH.Point
  ScrollbarHW.i
  ScrollbarHH.i
  Mouse.Point
EndStructure
Define Positions.Datas
With Positions
  \WW            = 640
  \WH            = 458
  \ScrollbarVW   = 20
  \ScrollbarVH   = \WH-20
  \ScrollbarV\x  = \WW-\ScrollbarVW
  \ScrollbarV\y  = 0
  \ScrollbarHH   = 20
  \ScrollbarHW   = \WW-20
  \ScrollbarH\x  = 0
  \ScrollbarH\y  = \WH-\ScrollbarHH
EndWith

Define Event.i

Procedure myResize()
  Shared Positions
  With Positions
    \WW=WindowWidth(1)
    \WH=WindowHeight(1)
    \ScrollbarVH   = \WH-20
    \ScrollbarHW   = \WW-20
    \ScrollbarV\x  = \WW-\ScrollbarVW
    \ScrollbarH\y  = \WH-\ScrollbarHH
    ResizeGadget(1, \ScrollbarV\x, #PB_Ignore, #PB_Ignore, \ScrollbarVH)
    ResizeGadget(2, #PB_Ignore, \ScrollbarH\y, \ScrollbarHW, #PB_Ignore)
  EndWith 
EndProcedure
Procedure Scroll(Direction)
  Shared Positions
  Protected.i x, y, Value, Stepsize
  x=WindowMouseX(1)
  y=WindowMouseY(1)
  Stepsize=1
  If GetAsyncKeyState_(#VK_CONTROL)
    Stepsize=(GetGadgetAttribute(1, #PB_ScrollBar_Maximum)-GetGadgetAttribute(1, #PB_ScrollBar_Minimum))/10
  EndIf
  With Positions
    If x>=\ScrollbarV\x
      If y<=\ScrollbarVH
        SetGadgetAttribute(1, #PB_ScrollBar_PageLength, Stepsize)
        If Direction
          Value=-1*Stepsize
        Else
          Value=1*Stepsize
        EndIf
        SetGadgetState(1, GetGadgetState(1)+Value)
      EndIf
    EndIf
    If y>=\ScrollbarH\y
      If x<=\ScrollbarHW
        SetGadgetAttribute(2, #PB_ScrollBar_PageLength, Stepsize)
        If Direction
          Value=-1*Stepsize
        Else
          Value=1*Stepsize
        EndIf
        SetGadgetState(2, GetGadgetState(2)+Value)
      EndIf
    EndIf
  EndWith
EndProcedure

With Positions
  OpenWindow(1, 10, 10, \WW, \WH, "", #PB_Window_SystemMenu|#PB_Window_SizeGadget)
  ScrollBarGadget(1, \ScrollbarV\x, \ScrollbarV\y, \ScrollbarVW, \ScrollbarVH, 1, 100, 1, #PB_ScrollBar_Vertical)
  ScrollBarGadget(2, \ScrollbarH\x, \ScrollbarH\y, \ScrollbarHW, \ScrollbarHH, 1, 100, 1)
EndWith

BindEvent(#PB_Event_SizeWindow, @myResize())

Repeat
  Event=WaitWindowEvent()
  If Event=#WM_MOUSEWHEEL
    GetAsyncKeyState_(#VK_CONTROL)
    Scroll((EventwParam()>>31)+1)
  EndIf
 
Until Event=#PB_Event_CloseWindow

But it's fine if you got a highresolution mouse and want to play with it. :wink:

_________________
Image


Top
 Profile  
Reply with quote  
 Post subject: Re: Keyboard shortcuts for mouse wheel
PostPosted: Wed Nov 20, 2019 3:21 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 13, 2010 3:45 pm
Posts: 940
@Lord
You just don't get it. Your nice example is nothing than unnecessary SchnickSchnack for this problem, because your basic mistake lies simply in your event loop:
Code:
Repeat
  Event=WaitWindowEvent()
  If Event=#WM_MOUSEWHEEL
    Scroll((EventwParam()>>31)+1)
  EndIf
Until Event=#PB_Event_CloseWindow

As I wrote before, you have no influence, when and how often a high resolution mousewheel fires an event. Only if the sum of the values in EventwParam() reaches a value of 120, your mouse wheel has the rotation angle back, which normally corresponds to a grid at the mousewheel.

Just a simple example: If you want to use the mouse wheel as middle mouse button, a high-resolution mouse wheel will surely fire several #WM_MOUSEWHEEL events, because the mouse wheel is also turned minimally when pressed. Then EventwParam() could look like this:

-3
+4
+2
-2

In this example your program already receives four events, your display will jump wildly up and down, although the user of your app only wanted to press the middle mouse button.


Lord wrote:
But it's fine if you got a highresolution mouse and want to play with it. :wink:
Wow, what ignorance. Maybe it should come in your consciousness that there are mice with high-resolution mouse wheels and if a programmer wants to call himself a programmer, then he should also consider this, especially if it is feasible with few additional lines of code. Mice with high-resolution mouse wheels are not only used by gamers, they are also used in CAD, which has absolutely nothing to do with playing.


But if you think that Microsoft is writing useless stuff, because you know better and you think that Fred has no idea that he has built this crap into the CanvasGadget, then just let it go.

_________________
sorry for my bad english


Top
 Profile  
Reply with quote  
 Post subject: Re: Keyboard shortcuts for mouse wheel
PostPosted: Wed Nov 20, 2019 4:47 pm 
Offline
Enthusiast
Enthusiast

Joined: Tue May 26, 2009 2:11 pm
Posts: 619
I just don't agree with you. That's all.
Josh wrote:
...
If you don't want to understand, I can't help you either.
...
Josh wrote:
But if you think that Microsoft is writing useless stuff, because you know better and you think that Fred has no idea that he has built this crap into the CanvasGadget, then just let it go.
And this disqualifies you for further answers
or even reading of your postings.
Have a nice day.

_________________
Image


Last edited by Lord on Thu Nov 21, 2019 2:07 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Keyboard shortcuts for mouse wheel
PostPosted: Fri Nov 29, 2019 12:45 am 
Offline
Addict
Addict

Joined: Mon Feb 16, 2015 2:49 pm
Posts: 1904
BarryG wrote:
Dude, try this. Just test -1 for up, and "else" for down

Thank you, it works on 64bit for me now. :)


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 35 posts ]  Go to page Previous  1, 2, 3

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye