MouseWheel Factor | Can control zoom factors for both 2D/3D!
Posted: Wed Aug 28, 2013 10:06 pm
After learning Purebasic a bit better thanks to a couple of kind souls who have helped me out immensely on this forum, I would like to dedicate my first ever code entry to those few individuals! Kudos guys!
I also credit the original creator of another mouse wheel code which was similar to this one. (I forgot where I found it on the forum).
And now...
The code!
MouseWheel.pb:
Enjoy, all! =)
I also credit the original creator of another mouse wheel code which was similar to this one. (I forgot where I found it on the forum).
And now...
The code!
MouseWheel.pb:
Code: Select all
;-------------------------
;==================================================
; Author: Mythros
; Operating System(s): ALL OS' as far as I know (haven't tested on anything but
; windows 7 64 bit)
; Date Created: August 28th, 2013 | 3:45 PM
;==================================================
;-------------------------
#Window = #PB_Any
#WM_MOUSEWHEEL = $20A
Procedure.w MouseWheelDelta()
x.w = ((EventwParam()>>16)&$FFFF)
ProcedureReturn -(x / 120)
EndProcedure
#zoomspeed = 1
Wheel = 0
wnd = OpenWindow(#Window, 0, 0, 800, 600, "Mouse Wheel Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
InitSprite()
InitKeyboard()
InitMouse()
OpenWindowedScreen(WindowID(wnd), 0, 0, 800, 600, 1, 0, 0, 0)
sgadget = StringGadget(#PB_Any, 1, 0, WindowWidth(wnd)-2, 25, "", #PB_String_ReadOnly | #PB_String_BorderLess)
DisableGadget(sgadget, 1)
Repeat
ClearScreen(RGB(240, 240, 240))
ExamineKeyboard()
Select WaitWindowEvent()
Case #PB_Event_CloseWindow: Quit=1
Case #WM_MOUSEWHEEL
If #zoomspeed >= 0
Wheel - MouseWheelDelta() * #zoomspeed
ElseIf #zoomspeed < 0
Wheel + MouseWheelDelta() * #zoomspeed
EndIf
EndSelect
SetGadgetText(sgadget, "Times Mousewheel has been scrolled with up or down: "+Str(Wheel))
Until KeyboardPushed(#PB_Key_Escape) Or Quit
; IDE Options = PureBasic v5.11 (Windows - x86)
; Folding = -