This flicker problem is why I never used SplitterGadget in PB
I've the same problem as you BarryG.
It's better with ChrisR code by adding 2 more UpdateWindow_() for gadget 0 and 1 in BindSplitterH() procedure :
Code: Select all
Global OldProc
Procedure SplitterProc(hWnd, uMsg, wParam, lParam)
Static SplitterPos
Select uMsg
Case #WM_NCDESTROY
Case #WM_PAINT
Protected Position = GetGadgetState(GetProp_(hWnd, "PB_ID"))
If SplitterPos <> Position
SplitterPos = Position
Else
ProcedureReturn #False
EndIf
EndSelect
ProcedureReturn CallWindowProc_(OldProc, hWnd, uMsg, wParam, lParam)
EndProcedure
Procedure BindSplitterV()
Static SplitterPos
Protected Position = GetGadgetState(EventGadget())
If SplitterPos <> Position
SplitterPos = Position
UpdateWindow_(GadgetID(0))
UpdateWindow_(GadgetID(1))
Debug "Vertical Splitter new position: " + Position
Else
Debug "Vertical Splitter Event received without position change: " + Position + " !"
EndIf
EndProcedure
Procedure BindSplitterH()
Static SplitterPos
Protected Position = GetGadgetState(EventGadget())
If SplitterPos <> Position
SplitterPos = Position
UpdateWindow_(GadgetID(3))
UpdateWindow_(GadgetID(0))
UpdateWindow_(GadgetID(1))
Debug "Horizontal Splitter new position: " + Position
Else
Debug "Horizontal Event received without position change: " + Position + " !"
EndIf
EndProcedure
Procedure WinResize()
ResizeGadget(4, #PB_Ignore, #PB_Ignore, WindowWidth(0)-10, WindowHeight(0)-10)
EndProcedure
OpenWindow(0, 0, 0, 400, 400, "Splitter", #PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget|#PB_Window_ScreenCentered|#PB_Window_Invisible)
ExplorerListGadget(0, 0, 0, 0, 0, GetUserDirectory(#PB_Directory_Desktop))
ExplorerListGadget(1, 0, 0, 0, 0, GetUserDirectory(#PB_Directory_Pictures))
SplitterGadget(2, 5, 5, 390, 390, 0, 1, #PB_Splitter_Vertical)
BindGadgetEvent(2, @BindSplitterV())
ExplorerListGadget(3, 0, 0, 0, 0, GetHomeDirectory())
SplitterGadget(4, 5, 5, 390, 390, 2, 3, #PB_Splitter_Separator)
BindGadgetEvent(4, @BindSplitterH())
SetGadgetState(4, 250)
; SubClass Splitter for WM_PAINT message can also help
;OldProc = GetWindowLongPtr_(GadgetID(4), #GWLP_WNDPROC)
;SetWindowLongPtr_(GadgetID(4), #GWLP_WNDPROC, @SplitterProc())
BindEvent(#PB_Event_SizeWindow, @WinResize())
HideWindow(0, #False)
While WaitWindowEvent() <> #PB_Event_CloseWindow : Wend