Just starting out? Need help? Post your questions and find answers here.
Joakim Christiansen
Addict
Posts: 2452 Joined: Wed Dec 22, 2004 4:12 pm
Location: Norway
Contact:
Post
by Joakim Christiansen » Wed Feb 08, 2006 10:25 pm
How can I get MouseWheel status without using ExamineMouse()?
Think I need some windows-api code!
Thanks!
PB
PureBasic Expert
Posts: 7581 Joined: Fri Apr 25, 2003 5:24 pm
Post
by PB » Wed Feb 08, 2006 10:35 pm
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
srod
PureBasic Expert
Posts: 10589 Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...
Post
by srod » Wed Feb 08, 2006 10:37 pm
If you mean to trap movements of the mousewheel, then look out for the #WM_MOUSEWHEEL message within your window callback.
I may look like a mule, but I'm not a complete ass.
blueznl
PureBasic Expert
Posts: 6166 Joined: Sat May 17, 2003 11:31 am
Contact:
Post
by blueznl » Thu Feb 09, 2006 4:22 pm
check on events, they're 511 and 512 iirc, one for up, one for down
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide
right here ... )
Sparkie
PureBatMan Forever
Posts: 2307 Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA
Post
by Sparkie » Thu Feb 09, 2006 6:21 pm
Detect mousewheel direction...
Code: Select all
Procedure.l WinCallback(hwnd, msg, wparam, lparam)
result = #PB_ProcessPureBasicEvents
Select msg
Case #WM_MOUSEWHEEL
If wparam < 0
direction$ = "Scrolling towards user"
Else
direction$ = "Scrolling away from user"
EndIf
SetGadgetText(0, direction$)
EndSelect
ProcedureReturn result
EndProcedure
If OpenWindow(0, 0, 0, 300, 200, #PB_Window_SystemMenu | #PB_Window_ScreenCentered, "Detect Mousewheel") And CreateGadgetList(WindowID(0))
SetWindowCallback(@WinCallback())
TextGadget(0, 10, 50, 280, 25, "", #PB_Text_Center)
Repeat
event = WaitWindowEvent()
Until event = #PB_Event_CloseWindow
EndIf
End
What goes around comes around.
PB 5.21 LTS (x86) - Windows 8.1
Joakim Christiansen
Addict
Posts: 2452 Joined: Wed Dec 22, 2004 4:12 pm
Location: Norway
Contact:
Post
by Joakim Christiansen » Thu Feb 09, 2006 6:25 pm
blueznl wrote: check on events, they're 511 and 512 iirc, one for up, one for down
That didn't work :roll:
PB
PureBasic Expert
Posts: 7581 Joined: Fri Apr 25, 2003 5:24 pm
Post
by PB » Thu Feb 09, 2006 9:19 pm
This is what I've been using:
Code: Select all
If OpenWindow(0,300,300,400,200,#PB_Window_SystemMenu,"test")
CreateGadgetList(WindowID(0))
TextGadget(0,20,20,200,20,"Scroll the mouse wheel...")
Repeat
ev=WaitWindowEvent()
If ev=#WM_MOUSEWHEEL
If EventwParam()>0
SetGadgetText(0,"UP")
ElseIf EventwParam()<0
SetGadgetText(0,"DOWN")
EndIf
EndIf
Until ev=#PB_Event_CloseWindow
EndIf
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
Sparkie
PureBatMan Forever
Posts: 2307 Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA
Post
by Sparkie » Thu Feb 09, 2006 10:06 pm
Speaking of EventwParam() (and EventlParam()), when I first joined the PB Board, I saw various posts that said not to use them as they will/may no longer be supported in future versions of PB.
viewtopic.php?p=59106#59106
viewtopic.php?p=49334#49334
viewtopic.php?p=66452#66452
Well here we are 2 years later with PB 4 and there they are, still functioning. Fred
What goes around comes around.
PB 5.21 LTS (x86) - Windows 8.1
Fred
Administrator
Posts: 18247 Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:
Post
by Fred » Thu Feb 09, 2006 10:08 pm
well, these two commands aren't 'officials' but it would probably hurt if we remove it as we can't replace it with something else. So it's still here..
Sparkie
PureBatMan Forever
Posts: 2307 Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA
Post
by Sparkie » Thu Feb 09, 2006 10:16 pm
Thanks Fred.
I think I'll still avoid using them, even though they are there.
What goes around comes around.
PB 5.21 LTS (x86) - Windows 8.1