Basic Univers
; Application du message WM_MOUSEWEEL
; scrolling via le bouton centrale de la souris

#WM_MOUSEWHEEL = $20A
Global Hscroll.l

Procedure ProcedureCallback(WindowID, Message, wParam, lParam)
  Resultat = #PB_ProcessPureBasicEvents
  ; Debug Message
  Select Message
    Case #WM_MOUSEWHEEL
      hi.w =(wParam>>16)
      lo.w = wParam & $FFFF
     
      If lo.w & #MK_MBUTTON
        ; indique le click de la molette seulement si celle-ci tourne
        MessageRequester("Info", "Click de la molette")
      EndIf
     
      coef = 4
      delta = hi*coef
      Debug delta
     
      While delta>120
        SendMessage_(Hscroll, #WM_VSCROLL, #SB_LINEUP, 0)
        delta = delta -(120 + coef)
      Wend
     
      While delta< - 120
        SendMessage_(Hscroll, #WM_VSCROLL, #SB_LINEDOWN, 0)
        delta = delta +(120 + coef)
      Wend
      Debug delta

  EndSelect
 
  ProcedureReturn Resultat
EndProcedure
 

If OpenWindow(0, 0, 0, 400, 400, "ScrollAreaGadget", #PB_Window_SystemMenu|#PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0))
  Hscroll = ScrollAreaGadget(0, 10, 10, 360, 300, 340, 800, 30)
  ButtonGadget(1, 10, 140, 230, 30, "Button 1")
  CloseGadgetList()
   
  SetWindowCallback(@ProcedureCallback())

  Repeat
    EventID.l = WaitWindowEvent()
    Select EventID
      Case #PB_Event_Gadget
        Select EventGadget()
          Case 1

        EndSelect
         
      Case #WM_CLOSE
        Quit = 1
    EndSelect
  Until Quit = 1
EndIf