SplitterGadget with more than two gadgets

Just starting out? Need help? Post your questions and find answers here.
BarryG
Addict
Addict
Posts: 4219
Joined: Thu Apr 18, 2019 8:17 am

Re: SplitterGadget with more than two gadgets

Post 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?
User avatar
chi
Addict
Addict
Posts: 1087
Joined: Sat May 05, 2007 5:31 pm
Location: Austria

Re: SplitterGadget with more than two gadgets

Post 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
Et cetera is my worst enemy
BarryG
Addict
Addict
Posts: 4219
Joined: Thu Apr 18, 2019 8:17 am

Re: SplitterGadget with more than two gadgets

Post by BarryG »

Here's how it looks on my PCs:

Image
User avatar
chi
Addict
Addict
Posts: 1087
Joined: Sat May 05, 2007 5:31 pm
Location: Austria

Re: SplitterGadget with more than two gadgets

Post 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 ;)
Et cetera is my worst enemy
tatanas
Enthusiast
Enthusiast
Posts: 260
Joined: Wed Nov 06, 2019 10:28 am
Location: France

Re: SplitterGadget with more than two gadgets

Post 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
Windows 10 Pro x64
PureBasic 6.20 x64
BarryG
Addict
Addict
Posts: 4219
Joined: Thu Apr 18, 2019 8:17 am

Re: SplitterGadget with more than two gadgets

Post by BarryG »

Thanks, tatanas! That fixed it for me. :D And glad to know I wasn't the only one who had the glitches.
Post Reply