Page 3 of 3

Re: SplitterGadget with more than two gadgets

Posted: Fri May 03, 2024 1:23 am
by BarryG
chi wrote: Thu May 02, 2024 3:31 pmI wonder why ResizeGadget is so much slower than SetWindowPos
Your latest example has the terrible glitching again, no matter if I set #USEWINAPI to 0 or 1. Don't know if you expected it to be gone, or just using that code as a different example?

Re: SplitterGadget with more than two gadgets

Posted: Fri May 03, 2024 3:49 am
by chi
BarryG wrote: Fri May 03, 2024 1:23 am
chi wrote: Thu May 02, 2024 3:31 pmI wonder why ResizeGadget is so much slower than SetWindowPos
Your latest example has the terrible glitching again, no matter if I set #USEWINAPI to 0 or 1. Don't know if you expected it to be gone, or just using that code as a different example?
This is just another case that also has an impact on the splitter problem. On my machine the glitching with SetWindowPos has almost disappeared, but with ResizeGadget I have a similar experience to yours...

Image

Re: SplitterGadget with more than two gadgets

Posted: Fri May 03, 2024 7:02 am
by BarryG
Here's how it looks on my PCs:

Image

Re: SplitterGadget with more than two gadgets

Posted: Fri May 03, 2024 7:37 am
by chi
BarryG wrote: Fri May 03, 2024 7:02 am Here's how it looks on my PCs
I see... Was worth a shot ;)

Re: SplitterGadget with more than two gadgets

Posted: Tue May 07, 2024 9:33 am
by tatanas
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

Re: SplitterGadget with more than two gadgets

Posted: Tue May 07, 2024 9:56 am
by BarryG
Thanks, tatanas! That fixed it for me. :D And glad to know I wasn't the only one who had the glitches.