Page 1 of 1

PanelGadget tab change flicker

Posted: Wed Mar 18, 2020 10:13 am
by BarryG
I have 10 tabs on a PanelGadget, with numerous gadgets on each one. When I click from one tab to another, there is a noticeable flicker when all gadgets redraw. Currently I can "fix" this in my window's main callback like below, but it still doesn't look ideal despite reducing the flicker a lot. Is there a better way?

Code: Select all

ElseIf Message=#WM_NOTIFY
  
  Select *pnmh\code
      
    Case #TCN_SELCHANGING ; Panel tab changing.
      
      LockWindowUpdate_(WindowID(0)) ; Stops panel flickering.
      
    Case #TCN_SELCHANGE ; Panel tab finished changing.
      
      LockWindowUpdate_(0)

Re: PanelGadget tab change flicker

Posted: Wed Mar 18, 2020 11:54 am
by RASHAD
Hi BarryG
1- Disable XP Theme for PanelGadget()
Or
2- Use ContainerGadget() for each tab

Re: PanelGadget tab change flicker

Posted: Wed Mar 18, 2020 12:14 pm
by BarryG
Hi Rashad. XP theme works but I don't really like the look. Tried ContainerGadgets() but the flicker is still there. I assume you meant to: add a panel tab, then a container for that tab, then all gadgets inside that container, then close the container gadget list, and then move on to adding the next panel tab with container and gadgets? That's what I did, and the flicker didn't go.

Re: PanelGadget tab change flicker

Posted: Wed Mar 18, 2020 12:45 pm
by RASHAD
Hi Barry
You did exactly what I meant but when you switch between tabs you should hide the container then show it (Create each container with it's objects after creating window then just add the container only after the tab item)
Or use

Code: Select all

      SetWindowLongPtr_(GadgetID(cont), #GWL_STYLE, GetWindowLongPtr_(GadgetID(cont), #GWL_STYLE) | #WS_CLIPSIBLINGS | #WS_CLIPCHILDREN)
      SetWindowPos_(GadgetID(cont), ##HWND_TOP, -1, -1, -1, -1, #SWP_NOSIZE | #SWP_NOMOVE)
3- Try to use Dialog lib it may help :P
That will be so hard to repeat the work from beginning :mrgreen:

Re: PanelGadget tab change flicker

Posted: Wed Mar 18, 2020 1:16 pm
by BarryG
Thanks again; will try all suggestions. As you said, it will take time.

Re: PanelGadget tab change flicker

Posted: Sat Mar 21, 2020 3:43 am
by RASHAD
Hi BarryG
Any luck with the panel flicker ?
Next may help I hope

Code: Select all

Procedure sizeCB()
  ResizeGadget(1,5,5,WindowWidth(0)-10,WindowHeight(0)-10)
  For gad = 10 To 30 Step 10
    ResizeGadget(gad,0,0,GadgetWidth(1)-8,GadgetHeight(1)-28)
  Next
EndProcedure
    
  OpenWindow(0, 0, 0, 400, 300, "PanelGadget with SetParent_()", #PB_Window_SystemMenu | #PB_Window_ScreenCentered |#PB_Window_SizeGadget)
  SmartWindowRefresh(0,1)   
  PanelGadget(1,5,5,390,290)  
    AddGadgetItem(1, -1, "1")
    AddGadgetItem(1, -1, "2")
    AddGadgetItem(1, -1, "3")
  CloseGadgetList()
    
  hWnd  = GetWindow_(GadgetID(1),#GW_CHILD)
  hWnd1 = GetWindow_(hWnd,#GW_HWNDNEXT)
  hWnd2 = GetWindow_(hWnd1,#GW_HWNDNEXT)

  w = GadgetWidth(1)-8
  h = GadgetHeight(1)-28
  
  ContainerGadget(10,0,0,w,h)
  SetGadgetColor(10, #PB_Gadget_BackColor, $E8E8E8)
    ButtonGadget(12,10,10,60,20,"RUN")
  CloseGadgetList()
  SetParent_(GadgetID(10),hwnd)
  
  ContainerGadget(20,0,0,w,h)
  SetGadgetColor(20, #PB_Gadget_BackColor, $D2FEFE)
    ButtonGadget(22,10,10,60,20,"RUN")
  CloseGadgetList()
  SetParent_(GadgetID(20),hwnd1) 
  
  ContainerGadget(30,0,0,w,h)
  SetGadgetColor(30, #PB_Gadget_BackColor, $D2FFDA)
    ButtonGadget(32,10,10,60,20,"RUN")
  CloseGadgetList()
  SetParent_(GadgetID(30),hwnd2) 
  
  BindEvent(#PB_Event_SizeWindow,@sizeCB())      

Repeat
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow
      Quit = 1
  
    Case #PB_Event_Gadget
      Select EventGadget()
        Case 0
          Select EventType()
            Case #PB_EventType_Change
              ;UpdateWindow_(GadgetID(1))
              ;InvalidateRect_(GadgetID(1),0,1)               
          EndSelect
          
        Case 12
          Debug "12"
          
        Case 22
          Debug "22"
        
        Case 32
          Debug "32"
      EndSelect
    
  EndSelect
Until Quit = 1

End