Discussion:
MouseWheel scroll in VBA form listbox. Tip for modeless forms
(too old to reply)
Os
2006-04-21 15:21:59 UTC
Permalink
There was a problem with mouse-scrolling listboxes on non-modal forms (no extra ActiveX controls
envolved!)(http://www.eggheadcafe.com/ng/microsoft.public.vb.winapi/post21996948.asp)

The solution (in case of modeless forms) is very simple, you should just add

Private Sub UserForm_Activate()
UserformHook ...........
End Sub

Private Sub UserForm_Deactivate()
UserformUnhook ............
End Sub

where UserformUnhook restores previously saved hook

this will remedy calling of WindowProc when form is not active - no more crashes, works smoothly
Actually now I just cannot imagine listboxes without mouse scrolling. How cool!
Os
2006-04-22 12:38:12 UTC
Permalink
By the way, I found it's not enough. One should have event handlers for all listboxes for MouseDown that hook windowProc,

and the most important - one should implement in windowProc check for WM_ACTIVATE wparam.loword=0 (which is "window about to
deactivate" message) and unhook windowProc

that's all
Post by Os
There was a problem with mouse-scrolling listboxes on non-modal forms (no extra ActiveX controls
envolved!)(http://www.eggheadcafe.com/ng/microsoft.public.vb.winapi/post21996948.asp)
The solution (in case of modeless forms) is very simple, you should just add
Private Sub UserForm_Activate()
UserformHook ...........
End Sub
Private Sub UserForm_Deactivate()
UserformUnhook ............
End Sub
where UserformUnhook restores previously saved hook
this will remedy calling of WindowProc when form is not active - no more crashes, works smoothly
Actually now I just cannot imagine listboxes without mouse scrolling. How cool!
Alessandro Baraldi
2006-04-22 18:33:14 UTC
Permalink
Try with this:
http://www.lebans.com/mousewheelonoff.htm

Bye
@Alex
Os
2006-04-22 19:42:39 UTC
Permalink
Thanx, I wanna dig it without dlls or any extra components.

I found at last that user_form_deactivate is not called when form is out of focus, so I checked what caused freezing and found that
I should unhook immediately in my WindowProc when it receives message WM_NCHITTEST (mouse is moved in non-client window area). And I
put handlers for all listboxes "Enter" event to re-enable windowproc hook.
So I solved myself the problem to 99%. Someday I will know how to handle MDI windowproc's more correctly.
Post by Alessandro Baraldi
http://www.lebans.com/mousewheelonoff.htm
Bye
@Alex
Alessandro Baraldi
2006-04-23 13:31:57 UTC
Permalink
On Access VBA each control have not the Handle until is activated, so
you will have alwais problem
with all controls and SubForm it's one of this...!
Sthepen built this Dll because the SubClass on VBA is not sure
tecnique, but i think that if you
write to him you can receive the openSource VC++ code.
It's much better delegate to an external component the SubClassing.

Bye
@Alex

Loading...