forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Capture scrollwheel scrolling?

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
Garrett
Moderator Team


Joined: 04 Oct 2001
Posts: 2149
Location: A House

PostPosted: Wed May 20, 2009 6:51 pm    Post subject: Capture scrollwheel scrolling? Reply with quote

I'm not sure this is possible and my mind is foggy right now. Maybe this has been covered before and I'm just not in the right mind right not to find it.

What I'm trying to do is this:

I have a window which uses the scroll bar in VDS 6. For me on Vista it doesn't seem that VDS recognizes the scrollwheel and scroll the scrollbar on my dialog when it's available. I would like to be able to add this ability to my dialog so the user doesn't have to do this manually.

Does anyone have any suggestions, help or info to get me started on this?

Thanks,
~Garrett

_________________
'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.)
Back to top
View user's profile Send private message
vdsalchemist
Admin Team


Joined: 23 Oct 2001
Posts: 1448
Location: Florida, USA

PostPosted: Fri May 22, 2009 7:17 pm    Post subject: Reply with quote

Here ya go...

Code:

#---------------------------------------------------------------------------------------#
#                                                                                       #
# Description: WM_MOUSEWHEEL example using VDS OPTION MSGEVENT command to trap          #
#              this message and forward it as a WM_VSCROLL to the VDS dialog's          #
#              vertical scrollbar.                                                      #
#                                                                                       #
# Copyright: Copyright © 2008 DragonSphere Software All Rights Reserved.                #
#                                                                                       #
#---------------------------------------------------------------------------------------#

#DEFINE FUNCTION,HasWheelScroll
  DIALOG CREATE,New Dialog,-1,0,164,139,SCROLLBARS
REM *** Modified by Dialog Designer on 5/22/2009 - 13:55 ***
  DIALOG ADD,EDIT,EDIT1,20,1,255,204,EDIT1
  DIALOG SHOW
%%WM_MOUSEWHEEL = $0000020A
%%WM_MOUSEHWHEEL = $0000020E
%%WHEEL_DELTA = 102

%%WM_VSCROLL = $00000115
%%WM_HSCROLL = $00000114
%%SB_LINEUP = 0
%%SB_LINELEFT = 0
%%SB_LINEDOWN = 1
%%SB_LINERIGHT = 1
%%SB_PAGEUP = 2
%%SB_PAGELEFT = 2
%%SB_PAGEDOWN = 3
%%SB_PAGERIGHT = 3
%%SB_THUMBPOSITION = 4
%%SB_THUMBTRACK = 5
%%SB_TOP = 6
%%SB_LEFT = 6
%%SB_BOTTOM = 7
%%SB_RIGHT = 7
%%SB_ENDSCROLL = 8

%%SPI_GETWHEELSCROLLLINES = 104
%%SPI_GETWHEELSCROLLCHARS = 108
%%SM_MOUSEWHEELPRESENT = 75
%%WindowIDWithScrollBar = @winexists(New Dialog)
%%WheelvScroll = @HasWheelScroll()
If %%WheelvScroll
  Option MSGEVENT,%%WM_MOUSEWHEEL,MOUSEVWHEEL,HANDLED
End

:EVLOOP
    Wait Event
   %E = @event()
   If %E
     Goto %E
   End
goto evloop

:CLOSE

STOP


:MOUSEVWHEEL
  # Forwards the WM_MOUSEWHEEL message to the Dialog's Vertical Scroll Bar
  %%wParam = @msgparams(W)
  %%lParam = @msgparams(L)
  %%zDelta = @div(%%wParam,65536)
  %%KeyModifier = @diff(%%wParam,@prod(%%zDelta,65536))
  %%MouseX = @div(%%lParam,65536)
  %%MouseY = @diff(%%lParam,@prod(%%MouseX,65536))
   %%linesToScroll = @Prod(@div(%%zDelta,%%WHEEL_DELTA),%%WheelvScroll)
  Dialog Set,EDIT1,VerticalScroll|%%linesToScroll|%%WheelvScroll|%%zDelta|%%KeyModifier|%%MouseX|%%MouseY

  If @Greater(%%zDelta,0)
     Repeat
      %A = @SendMsg(%%WindowIDWithScrollBar,%%WM_VSCROLL,%%SB_LINEUP,0)
         %%linesToScroll = @pred(%%linesToScroll)
     Until @Zero(%%linesToScroll)
  Else
     Repeat
      %A = @SendMsg(%%WindowIDWithScrollBar,%%WM_VSCROLL,%%SB_LINEDOWN,0) 
         %%linesToScroll = @succ(%%linesToScroll)
     Until @Zero(%%linesToScroll)
  End

Goto evloop

:HasWheelScroll
    LoadLib User32.dll
    %R =
    %w = @binary(DWORD,0)
      %c = @binary(DWORD,0)
    # See if da mousie has a scroll wheel
    If @unequal(@lib(User32,GetSystemMetrics,INT,INT:%%SM_MOUSEWHEELPRESENT),0)
       # Yup, it does
       If @lib(User32,SystemParametersInfoA,BOOL,INT:%%SPI_GETWHEELSCROLLLINES,INT:0,INT:@Addr("%w"),INT:0)
          %R = @val(%w)
       Else
         # Didn't retrieve a value, so use a default value
         %R = 3
       End
    End
      FreeLib User32.dll
Exit %R


Sorry it took so long. I was trying to get Horizontal scrolling to work too but I could not since it requires a different hook than the one that comes with VDS at least with WinXP and older. Vista supports natively the horizontal scroll so I should be able to implement it for Vista without a DLL.

_________________
Home of

Give VDS a new purpose!


Last edited by vdsalchemist on Tue May 26, 2009 1:38 pm; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Garrett
Moderator Team


Joined: 04 Oct 2001
Posts: 2149
Location: A House

PostPosted: Sat May 23, 2009 3:15 am    Post subject: Reply with quote

DragonSphere... You're a life saver!!! Many of the things I have done would not have been possible without your help. Thank you. Smile

~Garrett

_________________
'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.)
Back to top
View user's profile Send private message
DaveR
Valued Contributor
Valued Contributor


Joined: 03 Sep 2005
Posts: 413
Location: Australia

PostPosted: Sat May 23, 2009 4:14 am    Post subject: Reply with quote

DS (I forget your real name)

Very nice. That'll come in handy.

BTW, there's the same typo in 2 places in the posted code.
%%WHELL_DELTA should be %%WHEEL_DELTA


Just curious why you clear alphabetic local variables at the start of your user defined functions? (and commands)

example:
Code:
:HasWheelScroll
    %R =
    if blah
      %R = blah
    end
Exit %R

As I understand it, VDS creates a new set of local variables for each user defined function and command. I've always believed that this happens every time that the function or command is called (or 'entered' as it says in the help file). Therefore, as I understand it, there is no need to clear any of the %A..%Z local variables used in the function or command because they were just created, and are empty or null.

_________________
cheers

Dave
Back to top
View user's profile Send private message
Garrett
Moderator Team


Joined: 04 Oct 2001
Posts: 2149
Location: A House

PostPosted: Sat May 23, 2009 7:24 am    Post subject: Reply with quote

Probably clears the variables out of habit. I do the same thing, I always clear the variables before I use them to insure there's nothing in there that might muck things up.
_________________
'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.)
Back to top
View user's profile Send private message
vdsalchemist
Admin Team


Joined: 23 Oct 2001
Posts: 1448
Location: Florida, USA

PostPosted: Tue May 26, 2009 1:36 pm    Post subject: Reply with quote

The reason is due to the fact that I am a C programmer by trade and I have learned to never trust compilers and interpreters that claim they clear or set variables to known values... So it is like Garrett says I want to make sure that %R is null/nil so when the function returns and does not assign a value to %R that %R does not already have a value and returns garbage. This can easily happen when your playing around with Win32 API fuctions that allocate memory. Sometimes the allocations can overwrite protected memory which would cause a GPF memory error. It's just a safety net of sorts Wink BTW Oops sorry about the typo I am always in a hurry and can't spell for nothing... This could be why I am a programmer and not a Grammer teacher Wink Rolling Eyes Also this is why there is version .01 alpha, beta, then final which would work out all these things hehe what error... I see no stinking error...
_________________
Home of

Give VDS a new purpose!
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
DaveR
Valued Contributor
Valued Contributor


Joined: 03 Sep 2005
Posts: 413
Location: Australia

PostPosted: Wed May 27, 2009 8:54 am    Post subject: Reply with quote

Thanks guys.
_________________
cheers

Dave
Back to top
View user's profile Send private message
LiquidCode
Moderator Team


Joined: 05 Dec 2000
Posts: 1752
Location: Space and Time

PostPosted: Thu Jun 19, 2014 2:46 pm    Post subject: Reply with quote

Just found this and it works great when using a multi line edit box w/o scrollbars also! Just what I needed.

Thanks!

_________________
Chris
Http://theblindhouse.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Page 1 of 1

 
Jump to:  
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
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group