Page 1 of 1

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

Posted: Sun Oct 19, 2025 8:39 pm
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.

Re: PanelGadget - One by One (NOT tabs)

Posted: Sun Oct 19, 2025 9:21 pm
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()

Re: PanelGadget - One by One (NOT tabs)

Posted: Mon Oct 20, 2025 12:23 pm
by ZX80
ChrisR, thank you very much !
Your amendment did the trick ! You saved me a headache !
Thank you doc !