Hi
I do a similar thing with my images.
I do not use the mouse wheel to draw the zoom box.
I use the mouse down then while the mouse button is held down draw the zoom box.
Then when the mouse button is released I redraw the image zoomed to the box. No waiting for the mouse wheel to stop.
I do use the mouse wheel to provide a dynamic zoom so wheel up zooms in and wheel down zooms out.
Works very well with smaller images but gets clunky with large images as the mouse wheel generates loads of events.
My solution to the dynamic zoom was to add a flag to the redraw procedure so if it was drawing the image then any more calls were simply sent back.
I have quickly added some test code to your example just for the zoom and the stopped message is displayed?
Code: Select all
Global ZoomFactor.i = 1
Procedure.i DrawMyImage()
Static iLoop.i = #False
Define Count.i = 0
If iLoop = #True
ProcedureReturn #True
EndIf
iLoop = #True
;Redraw My Image
;Do some long process
;Waste some time
While Count < 10000000
count = count + 1
Wend
Debug "Image Drawn"
iLoop = #False
ProcedureReturn #False
EndProcedure
OpenWindow(1,0,0,400,400,"Test",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
CanvasGadget(1,10,10,380,380)
Repeat
event=WaitWindowEvent()
Select event
Case #PB_Event_Gadget
Select EventType()
Case #PB_EventType_MouseWheel
If GetGadgetAttribute(1,#PB_Canvas_WheelDelta)<>0
ZoomFactor = ZoomFactor + GetGadgetAttribute(1,#PB_Canvas_WheelDelta)
If DrawMyImage() = #True
Debug "Wheeling " ;+Str(GetGadgetAttribute(1,#PB_Canvas_WheelDelta))
EndIf
Else
Debug ""
Debug "Stoping!"
Debug "Final Draw Image With Zoom Factor = " + Str(ZoomFactor)
EndIf
EndSelect
EndSelect
Until event=#PB_Event_CloseWindow
CD
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.