PanelGadget tab change flicker

Windows specific forum
BarryG
Addict
Addict
Posts: 3324
Joined: Thu Apr 18, 2019 8:17 am

PanelGadget tab change flicker

Post 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)
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4663
Joined: Sun Apr 12, 2009 6:27 am

Re: PanelGadget tab change flicker

Post by RASHAD »

Hi BarryG
1- Disable XP Theme for PanelGadget()
Or
2- Use ContainerGadget() for each tab
Egypt my love
BarryG
Addict
Addict
Posts: 3324
Joined: Thu Apr 18, 2019 8:17 am

Re: PanelGadget tab change flicker

Post 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.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4663
Joined: Sun Apr 12, 2009 6:27 am

Re: PanelGadget tab change flicker

Post 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:
Egypt my love
BarryG
Addict
Addict
Posts: 3324
Joined: Thu Apr 18, 2019 8:17 am

Re: PanelGadget tab change flicker

Post by BarryG »

Thanks again; will try all suggestions. As you said, it will take time.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4663
Joined: Sun Apr 12, 2009 6:27 am

Re: PanelGadget tab change flicker

Post 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
Egypt my love
Post Reply