Container color strange behavior [Resolved]

Just starting out? Need help? Post your questions and find answers here.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5614
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Container color strange behavior [Resolved]

Post 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
Last edited by Kwai chang caine on Thu Dec 25, 2025 11:54 am, edited 1 time in total.
ImageThe happiness is a road...
Not a destination

PureBasic French Forum
User avatar
Bisonte
Addict
Addict
Posts: 1329
Joined: Tue Oct 09, 2007 2:15 am

Re: Container color strange behavior

Post 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
PureBasic 6.21 (Windows x64) | Windows 11 Pro | AsRock B850 Steel Legend Wifi | R7 9800x3D | 64GB RAM | RTX 5080 | ThermaltakeView 270 TG ARGB | build by vannicom​​
English is not my native language... (I often use DeepL.)
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5614
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Container color strange behavior

Post 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
ImageThe happiness is a road...
Not a destination

PureBasic French Forum
Post Reply