Page 1 of 2 12 LastLast
Results 1 to 15 of 26
  1. #1
    2 Star Lounger
    Join Date
    May 2001
    Location
    indiana
    Posts
    130
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Scroll Mouse Problem Fixed?? (access 97)

    i have looked everywhere to fix the problem of the scroll mouse scrolling through records on a form. here is what i found. i can't get it to work as of yet (some of the code lines come up red) could someone please look over the code to see how to get it to work? it is supposed to disable the scroll button on each form.

    This is added to a Module:

    Declare Function CallWindowProc Lib "user32" Alias _
    "CallWindowProcA" (ByVal lpPrevWndFunc As Long, _
    ByVal hwnd As Long, ByVal Msg As Long, _
    ByVal wParam As Long, ByVal lParam As Long) As Long

    Declare Function SetWindowLong Lib "user32" Alias _
    "SetWindowLongA" (ByVal hwnd As Long, _
    ByVal nIndex As Long, ByVal dwNewLong As Long) As Long

    Public Declare Function RegisterWindowMessage& Lib "user32" Alias "RegisterWindowMessageA" _
    (ByVal lpString As String)

    Public Const GWL_WNDPROC = -4
    Public IsHooked As Boolean
    Public lpPrevWndProc As Long
    Public gHW As Long

    Public Sub Hook()

    If IsHooked Then
    'MsgBox "Don't hook it twice without " & _
    ' "unhooking, or you will be unable to unhook it."
    IsHooked = True
    Else
    lpPrevWndProc = SetWindowLong(gHW, GWL_WNDPROC, _
    AddressOf WindowProc)
    IsHooked = True
    End If

    End Sub

    Public Sub Unhook()

    Dim temp As Long
    temp = SetWindowLong(gHW, GWL_WNDPROC, lpPrevWndProc)
    IsHooked = False

    End Sub

    Function WindowProc(ByVal hw As Long, ByVal uMsg As _
    Long, ByVal wParam As Long, ByVal lParam As Long) As Long

    If uMsg = GetMouseWheelMsg Then
    ' Debug.Print "Message: "; hw, uMsg, wParam, lParam
    WindowProc = 0
    Else
    WindowProc = CallWindowProc(lpPrevWndProc, hw, _
    uMsg, wParam, lParam)
    End If

    End Function

    Public Function GetMouseWheelMsg() As Long

    GetMouseWheelMsg = 522 'this works for Win98/2000, otherwise use
    'RegisterWindowMessage("MSWHEEL_ROLLMSG")

    End Function

    This is added to each Form:

    Sub Form_Load()

    'Store handle to this form's window
    gHW = Me.hwnd

    If IsHooked Then
    Call Unhook
    End If

    'Call procedure to begin capturing messages for this window
    Call Hook

    End Sub

    Private Sub Form_Unload(Cancel As Integer)
    'Call procedure to stop intercepting the messages for this window
    Call Unhook
    End Sub

  2. #2
    4 Star Lounger
    Join Date
    Jun 2001
    Location
    Sacramento, California, USA
    Posts
    491
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Scroll Mouse Problem Fixed?? (access 97)

    Mine comes up red line on:
    lpPrevWndProc = SetWindowLong(gHW, GWL_WNDPROC, _
    AddressOf WindowProc)

    If someone can help out here, this will be outstanding if it really does stop the mouse scroll.

    Where'd ya get the code from? Maybe the author could help us out?
    <img src=/S/crossfingers.gif border=0 alt=crossfingers width=17 height=16>

    Michael

  3. #3
    2 Star Lounger
    Join Date
    May 2001
    Location
    indiana
    Posts
    130
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Scroll Mouse Problem Fixed?? (access 97)

    that's where mine stops too. there is also one more place it stops, but i don't remember where.

    of course, i got this from someone who got it from someone who found it somewhere etc....

    anyway, i'm sure someone like charlotte could find the problem.... (let's see if she takes up the challenge! - i know you want to charlotte! ) <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

  4. #4
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Scroll Mouse Problem Fixed?? (access 97)

    Hi,
    I don't believe you can use this in versions of Office prior to 2000 as it involves a callback function. The AddressOf operator passes the address of a VBA function to the dll and is new to VBA6.
    Regards,
    Rory

    Microsoft MVP - Excel

  5. #5
    Star Lounger
    Join Date
    Feb 2002
    Posts
    56
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Scroll Mouse Problem Fixed?? (access 97)

    Have you tried taking the cursor to the end of the first red line

    lpPrevWndProc = SetWindowLong(gHW, GWL_WNDPROC, (delete the underscore and press delete)

    This should bring the next line up and continue the statement.

    P.S where do you put this code and how do you make it work.

  6. #6
    2 Star Lounger
    Join Date
    May 2001
    Location
    indiana
    Posts
    130
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Scroll Mouse Problem Fixed?? (access 97)

    now rory, i'm just going to have to disregard that last post.... it is entirely not what i wanted to hear <img src=/S/evilgrin.gif border=0 alt=evilgrin width=15 height=15>. anyway, does this mean that it would work with access 2000? is there any way around this for 97? grasping at straws here - this is one of the biggest unsolved problems that i have seen. thanks for your input

  7. #7
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Scroll Mouse Problem Fixed?? (access 97)

    I haven't tested it (don't have a scroll mouse at home) but the code certainly compiles quite happily. To the best of my knowledge there is no way of using a callback function in 97 or prior, but that's not to say that there isn't a workaround for this particular problem.
    Happy hunting....
    Regards,
    Rory

    Microsoft MVP - Excel

  8. #8
    4 Star Lounger
    Join Date
    Jun 2001
    Location
    Sacramento, California, USA
    Posts
    491
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Scroll Mouse Problem Fixed?? (access 97)

    Dave - Yes I already tried that. No go.
    I put the code in a new module and cut the parts out for the Form Load & Unload and pasted it into the forms module.

    If I am reading it correctly, it calls the function when the form loads and "undoes it" when unloading the form.

    So Rory, I guess WIN2000 + Acc97 won't cut it with this code?

    Hopefully someone, someday can modify it for A97.

    Thanks fellas.

    Michael

  9. #9
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Scroll Mouse Problem Fixed?? (access 97)

    Sadly, no. It has to be Office2k or above. There might I suppose be an API call to do the equivalent of the AddressOf operator - I'll see if I can find anything when I have some free time.
    Regards,
    Rory

    Microsoft MVP - Excel

  10. #10
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Scroll Mouse Problem Fixed?? (access 97)

    Access 97 handled callbacks. I haven't messed with this code to see what it actually does in 97, and I don't have time to for at least a few days. So have fun, guys! <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

    PS/ Access 97 doesn't handle AddressOf, as Rory pointed out, so I doubt you can make this work.
    Charlotte

  11. #11
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Scroll Mouse Problem Fixed?? (access 97)

    Good news, possibly. It is apparently possible to recreate the functionality of the AddressOf operator in Access 97. There's an article on the Access Web referring to another site with the code. You will however have to subscribe in order to view the code and there appear to be a number of warnings along with it!
    Hope that helps.
    Regards,
    Rory

    Microsoft MVP - Excel

  12. #12
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Scroll Mouse Problem Fixed?? (access 97)

    This zip file from the Trigeminal website contains a spreadsheet with an AddrOf function in it which allegedly works in Office 97. You can see from the comments in the code that it was fun to work out!
    You will need to replace the
    AddressOf procname
    in the module you've got with:
    AddrOf("procname")
    and then hopefully it should work. I'd strongly recommend backing up your database first as this is not supported by MS in any way.
    Hope that helps.
    Regards,
    Rory

    Microsoft MVP - Excel

  13. #13
    2 Star Lounger
    Join Date
    May 2001
    Location
    indiana
    Posts
    130
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Scroll Mouse Problem Fixed?? (access 97)

    wow, this is getting deep....
    it is now giving an "argument not optional" for addrof(windowproc) and it is highlighting "windowproc". this is getting a bit over my head. it would be greatly appreciated by all if you could test it out to see if you can get it to work. thanks for your help so far!

  14. #14
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Scroll Mouse Problem Fixed?? (access 97)

    It should read
    AddrOf("windowproc")
    rather than
    AddrOf(windowproc)
    Does that help?
    I can't test it as I don't have Access97.
    Regards,
    Rory

    Microsoft MVP - Excel

  15. #15
    2 Star Lounger
    Join Date
    May 2001
    Location
    indiana
    Posts
    130
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Scroll Mouse Problem Fixed?? (access 97)

    well...

    as it sits, it stops and gives the error "Sub or function not defined" at "addrof", so i added the code:

    Public Function AddrOf(WindowProc) As Long

    End Function

    which satisfied the error, but ended up making all the code apparently do nothing. i found that bit of code in the spreadsheet you told me to look at. perhaps i coded it incorrectly or there probably needs to be some code in that fuction, but heaven knows i have no idea what that code may be. make any sense? <img src=/S/scratch.gif border=0 alt=scratch width=25 height=29>

Page 1 of 2 12 LastLast

Posting Permissions

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