Home > Uncategorized > Supporting the Mouse Wheel in VB6

Supporting the Mouse Wheel in VB6

VB6 does not natively support the mouse wheel (The roller ball in the middle of your mouse). Thus, any programs you develop with VB6 will not support the mouse wheel either. There is a work around.
 
Some websites will show a "hacky solution", which can cause vb6 to crash every time you press the "stop debug button" – this approach is better.
 
1st stop. Download the VB subclassing DLL from VBAccelerator.com. (SSubTmr.dll)
– Add a reference to this in the project
 
2. Add this constant
Public Const WM_MOUSEWHEEL = &H20A
 
3. Add this to the top of the form
Implements ISubclass
 
4.Add these three functions to the code
 Private Property Let ISubClass_MsgResponse(ByVal RHS As EMsgResponse)
 End Property
 Private Function ISubClass_WindowProc( _
  ByVal hwnd As Long, _
  ByVal iMsg As Long, _
  ByVal wParam As Long, _
  ByVal lParam As Long) As Long
 Dim rotation As Long
 rotation = wParam / 65536
 If rotation > 0 Then SendKeys ("{UP}")
 If rotation < 0 Then SendKeys ("{DOWN}")
End Function
  Private Property Get ISubClass_MsgResponse() As EMsgResponse
     ISubClass_MsgResponse = emrConsume
  End Property
And that’s it.
 
 
 
 
Advertisements
Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: