[Solved] PanelGadget - One by One (NOT tabs)

Just starting out? Need help? Post your questions and find answers here.
ZX80
Enthusiast
Enthusiast
Posts: 375
Joined: Mon Dec 12, 2016 1:37 pm

[Solved] PanelGadget - One by One (NOT tabs)

Post by ZX80 »

Hello, everyone.

I encountered the difficulty described in the topic title. My goal is to show an additional gadget when the window is resized. Most of the time the window is in a shortened form. Only sometimes I need to look at additional information. Here's a small snippet of basic code to help you understand what I want to do.

Code: Select all

Enumeration Gadgets
  #PanelGadget
  #PanelGadget2
  #ContainerGadget
  #ContainerGadget2
  #EditorGadget
  #ButtonGadget
  #ListViewGadget
EndEnumeration


Define hWnd.i, EvGad.i, Quit.i
Define state.i


If OpenWindow(0, 0, 0, 622, 250, "test window", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  hWnd = WindowID(0)

  PanelGadget(#PanelGadget, 8, 8, 608, 220)
  AddGadgetItem(#PanelGadget, 0, "123")
  ContainerGadget(#ContainerGadget, 0, 0, GetGadgetAttribute(#PanelGadget, #PB_Panel_ItemWidth), GetGadgetAttribute(#PanelGadget, #PB_Panel_ItemHeight))
  EditorGadget(#EditorGadget, 8, 8, 584, 131)
  ButtonGadget(#ButtonGadget, 8, 150, 80, 30, "expand")
  CloseGadgetList()
  
  PanelGadget(#PanelGadget2, 8, 250, 608, 200)
  AddGadgetItem(#PanelGadget2, 0, "details")
  ContainerGadget(#ContainerGadget2, 0, 0, GetGadgetAttribute(#PanelGadget2, #PB_Panel_ItemWidth), GetGadgetAttribute(#PanelGadget2, #PB_Panel_ItemHeight))
  ListViewGadget(#ListViewGadget, 8, 259, 584, 150)
  CloseGadgetList()
  
  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_CloseWindow
        Quit = 1
        
      Case #PB_Event_Gadget
        EvGad = EventGadget()
        If EvGad = #ButtonGadget
          state ! 1
          If state
            SetGadgetText(#ButtonGadget, "collapse")
            ResizeWindow(0, #PB_Ignore, #PB_Ignore, #PB_Ignore, 500)
          Else
            ResizeWindow(0, #PB_Ignore, #PB_Ignore, #PB_Ignore, 250)
            SetGadgetText(#ButtonGadget, "expand")
          EndIf
        EndIf
    EndSelect
  Until Quit = 1
EndIf
I expected to see the ListViewGadget at the bottom of the window at full size, but that doesn't happen.

Thank you for your help.
Last edited by ZX80 on Mon Oct 20, 2025 12:24 pm, edited 2 times in total.
User avatar
ChrisR
Addict
Addict
Posts: 1484
Joined: Sun Jan 08, 2017 10:27 pm
Location: France

Re: PanelGadget - One by One (NOT tabs)

Post by ChrisR »

PanelGadget and ContainerGadget use a gadget list, so you need 2 additional CloseGadgetList() + correction of the y position of the ListViewGadget

Code: Select all

  PanelGadget(#PanelGadget, 8, 8, 608, 220)
  AddGadgetItem(#PanelGadget, 0, "123")
  ContainerGadget(#ContainerGadget, 0, 0, GetGadgetAttribute(#PanelGadget, #PB_Panel_ItemWidth), GetGadgetAttribute(#PanelGadget, #PB_Panel_ItemHeight))
  EditorGadget(#EditorGadget, 8, 8, 584, 131)
  ButtonGadget(#ButtonGadget, 8, 150, 80, 30, "expand")
  CloseGadgetList()
  CloseGadgetList()
  
  PanelGadget(#PanelGadget2, 8, 250, 608, 200)
  AddGadgetItem(#PanelGadget2, 0, "details")
  ContainerGadget(#ContainerGadget2, 0, 0, GetGadgetAttribute(#PanelGadget2, #PB_Panel_ItemWidth), GetGadgetAttribute(#PanelGadget2, #PB_Panel_ItemHeight))
  ListViewGadget(#ListViewGadget, 8, 8, 584, 150)
  For a=1 To 12
      AddGadgetItem (#ListViewGadget,-1,"Item "+Str(a)+" of ListView")
    Next
  CloseGadgetList()
  CloseGadgetList()
ZX80
Enthusiast
Enthusiast
Posts: 375
Joined: Mon Dec 12, 2016 1:37 pm

Re: PanelGadget - One by One (NOT tabs)

Post by ZX80 »

ChrisR, thank you very much !
Your amendment did the trick ! You saved me a headache !
Thank you doc !
Post Reply