PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
How do I activate mouse's scrollwheel-VBForums
Results 1 to 19 of 19

Thread: How do I activate mouse's scrollwheel

  1. #1

    Thread Starter
    Hyperactive Member greaseman's Avatar
    Join Date
    Jul 2005
    Location
    Somewhere, out there...
    Posts
    295

    How do I activate mouse's scrollwheel

    I have a project that can display a lot of data in a form. The form has a scrollbar on one side and I can click on the scrollbar and move up or down in the data.

    My question: How can I activate my mouse's scrollwheel so that I can roll the scroll wheel and move up or down in the data?

    Thanks in advance to those who offer assistance!!

  2. #2
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,692

    Re: How do I activate mouse's scrollwheel

    Try the first post in this thread, but substitute the scroll bar's hwnd for Me.hwnd in the FormLoad sub.
    The most difficult part of developing a program is understanding the problem.
    The second most difficult part is deciding how you're going to solve the problem.
    Actually writing the program (translating your solution into some computer language) is the easiest part.

    Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.

    Please Help Us To Save Ana

  3. #3
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: How do I activate mouse's scrollwheel

    take a look at the mousewheel link in my sig.

  4. #4

    Thread Starter
    Hyperactive Member greaseman's Avatar
    Join Date
    Jul 2005
    Location
    Somewhere, out there...
    Posts
    295

    Re: How do I activate mouse's scrollwheel

    al42 and bushmobile,

    Thanks for your replies! I'll give the suggestion a shot and see what comes up!

    I'll let you know as soon as possible if it does the trick for me.

  5. #5

    Thread Starter
    Hyperactive Member greaseman's Avatar
    Join Date
    Jul 2005
    Location
    Somewhere, out there...
    Posts
    295

    Re: How do I activate mouse's scrollwheel

    al42 and bushmobile,

    I tried your suggestions, but they did not work. I ended up downloaded a file from Microsoft's site that installed Microsoft Intelliware 4.12 and that did the trick for me.

    I appreciate your offers of help.....keep up the good work!

    Thanks!

  6. #6
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: How do I activate mouse's scrollwheel

    You can do it with the code i linked to - you'd have to modify it though.

    Bear in mind that if you give your app to anyone else it might not work for them. if it's just for you then updating the driver is ok - if it's for other people then you'll have to handle the messages yourself.

  7. #7

    Thread Starter
    Hyperactive Member greaseman's Avatar
    Join Date
    Jul 2005
    Location
    Somewhere, out there...
    Posts
    295

    Re: How do I activate mouse's scrollwheel

    bushmobile,

    I'm thinking perhaps I didn't modify your code correctly. Can you tell me where I'd modify the code, if my form was named "ThisIsJustATest", and the field I am interested in is "FieldThisIsAField" ??


    Would I have to put the "CallWheelHook" into every field, or just at the beginning of a form?

    Thanks in advance! I appreciate your help.

  8. #8

    Thread Starter
    Hyperactive Member greaseman's Avatar
    Join Date
    Jul 2005
    Location
    Somewhere, out there...
    Posts
    295

    Re: How do I activate mouse's scrollwheel

    bushmobile,

    Are you there????

  9. #9
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: How do I activate mouse's scrollwheel

    sorry, i haven't got VB on this computer and can't get access to the code.

    From memory it should be something like this:
    VB Code:
    1. ' On the Form:
    2. Private Sub MouseWheel(...Parameters...)
    3.     '
    4.     ' code
    5.     Select Case blah
    6.         ' Leave the
    7.         ' Case TypeOf ctl Is TextBox.... one
    8.         ' and the Case Else one - get rid of the others
    9.     End Select
    10.    
    11.     ' Where it has
    12.     Me.Caption = IIf(... 'or something
    13.     ' either decrease or increase the VScrollBars value according the value of rotation
    14. End Sub
    If you post the sub i mentioned above I should be able to help you out more.

  10. #10
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: How do I activate mouse's scrollwheel

    finally got VB back - here's an example (it's not brilliant but it should point you in the right direction)

    Attached Files Attached Files

  11. #11
    Addicted Member
    Join Date
    Mar 2006
    Posts
    160

    Re: How do I activate mouse's scrollwheel

    Hi BushMobile,

    Great piece of code/example. However I think I found a bug.

    The error is
    Code:
    Runtime Error 91
    Object variable or with block variable not set
    The steps to generate the error are:

    1) Place a textbox inside a picturebox.
    2) click inside the textbox and rotate the wheel. (Which is obviously ignored by your MouseWheel event.) (everything is still fine)
    2) move the mouse outside the bounds of the textbox (in my case pointer is now over picturebox) but DO NOT click the mouse.
    3) Error is generated when you roll the mousewheel over the picturebox.

    I suspect your routine thinks it's still over the textbox, and has to do with VB not detecting when the mouse leaves the bounds of a control too well?

    Regards,
    Nap

    PS.. Wish I could fix it for you, but I'm not that skilled with API code. But would love it if you found the answer ASAP.

  12. #12
    Addicted Member
    Join Date
    Mar 2006
    Posts
    160

    Re: How do I activate mouse's scrollwheel

    Hi BushMobile,

    I have been able to eliminate the error from occuring some of the time by:

    Code:
    picturebox_mousemove (....)
    picturebox.setfocus
    end sub
    But the error still occurs when there is a small gap between textboxes and you happen to be scrolling while the mouse moves over the gap. As I said b4, VB isn't good at detecting when the mouse moves off the control.

    Cheers,
    Nap

  13. #13
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: How do I activate mouse's scrollwheel

    have a look at posts #14 - #17 in the codebank thread - that'll fix the error.

    but the textbox will only scroll if it has focus - so i'm just going to see if can do something to fix that.

  14. #14
    Addicted Member
    Join Date
    Mar 2006
    Posts
    160

    Re: How do I activate mouse's scrollwheel

    Understand about the texbox. The error happens when you give the textbox focus and then move off it without clicking the mouse over the next control it's hovering over.

    everything is working, except when there is a transition of the mouse over controls. If you move too quick and rotate the wheel while you're doing it, the error is generated.

    I will look at posts 14 - 17 now.

    Thanks & Cheers,
    Nap

  15. #15
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: How do I activate mouse's scrollwheel

    and the fix is:
    VB Code:
    1. Public Sub MouseWheel(ByVal MouseKeys As Long, ByVal Rotation As Long, ByVal Xpos As Long, ByVal Ypos As Long)
    2.   Dim ctl As Control, cContainerCtl As Control
    3.   Dim bHandled As Boolean
    4.   Dim bOver As Boolean
    5.  
    6.   For Each ctl In Controls
    7.   '
    8.   '
    9.        ' change this case
    10.         Case TypeOf ctl Is PictureBox, TypeOf ctl Is Frame
    11.           Set cContainerCtl = ctl: bHandled = False
    12.   '
    13.   '
    14.   Next ctl
    15.  
    16.   If Not cContainerCtl Is Nothing Then
    17.     If TypeOf cContainerCtl Is PictureBox Then PictureBoxZoom cContainerCtl, MouseKeys, Rotation, Xpos, Ypos
    18.   Else
    19.     ' Scroll was not handled by any controls, so treat as a general message send to the form
    20.     Me.Caption = "Form Scroll " & IIf(Rotation < 0, "Down", "Up")
    21.   End If
    22. End Sub
    only change the PictureBox case in the sub, keep the rest of the loop the same.

  16. #16
    Addicted Member
    Join Date
    Mar 2006
    Posts
    160

    Re: How do I activate mouse's scrollwheel

    nope, still getting the same error.
    Try to move the mouse off the textbox while rolling the wheel at the same time.

    I don't know if it's significant or not, but I'm not using a frame in my code. Just a textbox inside a picturebox.

    Cheers,
    Nap

  17. #17
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: How do I activate mouse's scrollwheel

    have a look at the CodeBank thread, I've just added a Nested Controls example

  18. #18
    Addicted Member
    Join Date
    Mar 2006
    Posts
    160

    Re: How do I activate mouse's scrollwheel

    After I changed the code to use the GetAncestor API, it worked. As per Post 15.

    Thank you very much.

    Cheers,
    Nap

  19. #19
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: How do I activate mouse's scrollwheel

    yes - the previous fix i mentioned was in addition to the use of GetAncestor, I probably didn't make that clear...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width