Page 1 of 1

Container color strange behavior [Resolved]

Posted: Wed Dec 24, 2025 9:16 pm
by Kwai chang caine
Hello at all

At your advice, why the Panel 2 and 3 not show the same colors :shock:
Yet the PbId is never the same

Code: Select all

OpenWindow(0,0,0,800,600,"Panels",#PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_SizeGadget|#PB_Window_MaximizeGadget)

For i = 1 To 4
 
 PanelGadget(i, Offset, 0, 200, WindowHeight(0))
 
  AddGadgetItem(i, -1, "Onglet 1")
   
   Id = ContainerGadget(#PB_Any,Offset,0,300,WindowHeight(0))
   Debug id
   CloseGadgetList()
   SetGadgetColor(Id, #PB_Gadget_BackColor, #Black)
       
  AddGadgetItem(i, -1, "Onglet 2")
  
   id = ContainerGadget(#PB_Any,Offset,0,300,WindowHeight(0))
   Debug id
   CloseGadgetList()
   SetGadgetColor(Id, #PB_Gadget_BackColor, #Red)
   
  AddGadgetItem(i, -1, "Onglet 3")
  
   id = ContainerGadget(#PB_Any,Offset,0,300,WindowHeight(0))
   Debug id
   CloseGadgetList()
   SetGadgetColor(Id, #PB_Gadget_BackColor, #Yellow)
      
 CloseGadgetList()
 Offset + 200
 
Next

Repeat  
 
 Evenement = WaitWindowEvent()
 EvenementGadget = EventGadget()
 EvenementType = EventType()
  
Until Evenement = #PB_Event_CloseWindow
Have a good day

Re: Container color strange behavior

Posted: Wed Dec 24, 2025 11:09 pm
by Bisonte
The cause is your Offset Variable...

you dont see the container at the second stage of your For.. Next loop.

You set the container x out of the panel ;)

Code: Select all

OpenWindow(0,0,0,800,600,"Panels",#PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_SizeGadget|#PB_Window_MaximizeGadget)

For i = 1 To 4
 
 PanelGadget(i, Offset, 0, 200, WindowHeight(0))
 
  AddGadgetItem(i, -1, "Onglet 1")
   
   Id = ContainerGadget(#PB_Any,0,0,300,WindowHeight(0))
   Debug id
   CloseGadgetList()
   SetGadgetColor(Id, #PB_Gadget_BackColor, #Black)
       
  AddGadgetItem(i, -1, "Onglet 2")
  
   id = ContainerGadget(#PB_Any,0,0,300,WindowHeight(0))
   Debug id
   CloseGadgetList()
   SetGadgetColor(Id, #PB_Gadget_BackColor, #Red)
   
  AddGadgetItem(i, -1, "Onglet 3")
  
   id = ContainerGadget(#PB_Any,0,0,300,WindowHeight(0))
   Debug id
   CloseGadgetList()
   SetGadgetColor(Id, #PB_Gadget_BackColor, #Yellow)
      
 CloseGadgetList()
 Offset + 200
 
Next

Repeat  
 
 Evenement = WaitWindowEvent()
 EvenementGadget = EventGadget()
 EvenementType = EventType()
  
Until Evenement = #PB_Event_CloseWindow

Re: Container color strange behavior

Posted: Thu Dec 25, 2025 11:54 am
by Kwai chang caine
Hello BISONTE

I have searched two hours, put CloseGadgetList() by here, put "offset" over there, and impossible to understand the problem :oops:
I have do this error, because in other version of this code when i have all trying (All except the good method :mrgreen:) i surely forgotten a CloseGadgetList() somewhere, and the containerGadget refered to the left of the window :shock:
That surprised me, because i'm really sure the "Panel" have is own space to write inside him...

Sometime we write a full and long code, not found the bugs and try the more simple working code for at less, for beginning on the good base, and stop to turning round... 8)
But here,...even the more simple code of the world not worked for KCC, I was on the brink of the abyss. :|

Thanks a lot BISONTE, for your precious help,
And have the best christmas Imageof the world

Image