'Just a note of caution. This solution makes use of a "hook" into the Windows message stream directed 
'at your program form. If you introduce an error into the WindowProc() function (detailed below) 
'Please make sure that you save your program before testing

'First declare the Windows functions and the variables and constants shown.
' These are perhaps best added to a code module.
$INCLUDE "\rapidq\include\windows.inc"
$INCLUDE "\rapidq\include\rapidq2.inc"


Dim LocalHwnd As Long
Dim LocalPrevWndProc As Long
Dim MyForm As QForm
DIM D as QDebug
D.Enabled = False

Function MyWindowProc(Lwnd As Long, Lmsg As Long, Wparam As Long, Lparam As Long) As Long

    Dim MouseKeys As Long
    Dim Rotation As Long
    Dim Xpos As Long
    Dim Ypos As Long

    If Lmsg = WM_MOUSEWHEEL Then
        MouseKeys = Wparam And 65535
        Rotation = Wparam / 65536
        Xpos = Lparam And 65535
        Ypos = Lparam / 65536
D.Print Rotation , "rotation"
        'MyForm.MouseWheel MouseKeys, Rotation, Xpos, Ypos
    End If
    'WindowProc = CallWindowProc(LocalPrevWndProc, Lwnd, Lmsg, Wparam, Lparam)
End Function


Sub WheelHook(PassedForm As QForm)

    'Set MyForm = PassedForm
    'LocalHwnd = PassedForm.hWnd
	'set a new address of the WinProc procedure
    'LocalPrevWndProc = SetWindowLong(LocalHwnd, GWL_WNDPROC, AddressOf WindowProc)
End Sub


Public Sub WheelUnHook()
    Dim WorkFlag As Long

    'WorkFlag = SetWindowLong(LocalHwnd, GWL_WNDPROC, LocalPrevWndProc)
    'Set MyForm = Nothing
End Sub

'To activate the hook into the Windows message stream that 
'detects the mouse wheel "event" you should call the 
'WheelHook() Sub from the relevant Form Activate event. 
'You should also remember to call the WheelUnHook() Sub 
'from the Deactivate event. This cleans up by deactivating 
'the hook into the relevant message stream but also means 
'that you can apply this technique to multiple forms in your application.

'You will note that the WindowProc() function calls a routine 
'on the form passed to the WheelHook() Sub as an argument. 
'This routine is (arbitrarily) called MouseWheel() and has a 
'number of arguments. 
DIM mMSG AS MSG

SUB GetIt
	DIM i as long
	mMSG.wParam = 0
	GetMessage(mMSG, 0&,WM_MOUSEWHEEL, WM_MOUSEWHEEL)		'blocks until message recieved...
	i++
	IF i >60 THEN i = 0
		myForm.TextOut( 0,i*10, "                                             ", 0,&Hffffff)
		myForm.TextOut( 0,i*10, str$(mMSG.wParam/&H780000) + "    "+ str$(mMSG.lParam), 0,-1)
END SUB


SUB loopit
	DIM i as long
	Do
	mMSG.wParam = 0
	IF PeekMessage (mMSG, 0&, WM_MOUSEWHEEL, WM_MOUSEWHEEL, PM_REMOVE) THEN		'for all thread handles
	'PeekMessage (mMSG, MyForm.Handle, WM_MOUSEWHEEL-1, WM_MOUSEWHEEL+1, PM_REMOVE)  'for one handle
	i++
	IF i >60 THEN i = 0
		myForm.TextOut( 0,i*10, "                                             ", 0,&Hffffff)
		myForm.TextOut( 0,i*10, str$(mMSG.wParam/&H780000) + "    "+ str$(mMSG.lParam), 0,-1)
	END IF
	Loop UNTIL (mMSG.wParam/&H780000 = 1)
END SUB


myForm.OnClick = GetIt	'loopit
myForm.Height =700
'MyForm.WndProc = MyWindowProc
Myform.ShowModal