Ach ja, wegen den Events vom Scrollbar.
Es scheint das PB nur ein Pull von Event bei BindEvent verwendet. Das passt aber nicht immer wie man es braucht.
Vielleicht SetGadgetCallback die Messages von Control selber auswerten.
Code:
;-TOP
; Comment : Module SetGadgetCallback (Windows Only)
; Author : mk-soft
; Version : v0.02
; Created : 10.06.2018
; Updated :
;
; Syntax Callback:
; Procedure GadgetCB(hWnd,uMsg,wParam,lParam)
; Select uMsg
; ;TODO
; EndSelect
; ; Call previous gadget procedure
; ProcedureReturn CallGadgetProc(hWnd,uMsg,wParam,lParam)
; EndProcedure
;
; *****************************************************************************
DeclareModule GadgetCallback
Declare SetGadgetCallback(Gadget, *lpNewFunc)
Declare CallGadgetProc(hWnd, uMsg, wParam, lParam)
EndDeclareModule
Module GadgetCallback
EnableExplicit
Global NewMap *lpPrevFunc()
Global MutexCB = CreateMutex()
; ---------------------------------------------------------------------------
Procedure SetGadgetCallback(Gadget, *lpNewFunc)
Protected GadgetID, GadgetKey.s
GadgetID = GadgetID(Gadget)
GadgetKey = Hex(GadgetID)
; Remove exists Callback
If FindMapElement(*lpPrevFunc(), GadgetKey)
SetWindowLongPtr_(GadgetID, #GWL_WNDPROC, *lpPrevFunc())
DeleteMapElement(*lpPrevFunc())
EndIf
If *lpNewFunc
If AddMapElement(*lpPrevFunc(), GadgetKey)
*lpPrevFunc() = SetWindowLongPtr_(GadgetID, #GWL_WNDPROC, *lpNewFunc)
ProcedureReturn *lpPrevFunc()
EndIf
EndIf
ProcedureReturn 0
EndProcedure
; ---------------------------------------------------------------------------
Procedure CallGadgetProc(hWnd, uMsg, wParam, lParam)
Protected result
LockMutex(MutexCB)
If FindMapElement(*lpPrevFunc(), Hex(hWnd))
result = CallWindowProc_(*lpPrevFunc(), hWnd, uMsg, wParam, lParam)
EndIf
UnlockMutex(MutexCB)
ProcedureReturn result
EndProcedure
EndModule
; *****************************************************************************
EnableExplicit
UseModule GadgetCallback
Procedure GadgetCB(hWnd,uMsg,wParam,lParam)
Select uMsg
Case #SBM_SETSCROLLINFO
Debug "#SBM_SETSCROLLINFO"
Case #SBM_GETSCROLLINFO
Debug "#SBM_GETSCROLLINFO"
EndSelect
ProcedureReturn CallGadgetProc(hWnd,uMsg,wParam,lParam)
EndProcedure
Procedure BindHScrollDatas()
Static.i iProcedureCalls = 1
; Filter
If GetGadgetData(EventGadget()) <> GetGadgetState(EventGadget())
SetGadgetData(EventGadget(), GetGadgetState(EventGadget()))
Debug "BindEventProcedure call #" + Str(iProcedureCalls) + " Position = " + GetGadgetState(0)
iProcedureCalls + 1
EndIf
EndProcedure
Global.i iEvent, iEventLoopCalls = 1
If OpenWindow(0, 0, 0, 380, 120, "ScrollBarGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ScrollBarGadget (0, 10, 40, 350, 20, 0, 100, 30)
SetGadgetState (0, 50) ; setze den ersten Scrollbalken (ID = 0) auf 50 von 100
SetGadgetCallback(0, @GadgetCB())
BindGadgetEvent(0, @BindHScrollDatas())
Repeat
iEvent = WaitWindowEvent()
Select iEvent
Case #PB_Event_Gadget
Select EventGadget()
Case 0
Debug "Eventloop call #" + Str(iEventLoopCalls)
iEventLoopCalls + 1
EndSelect
Case #PB_Event_CloseWindow
End
EndSelect
ForEver
EndIf