Page 1 of 1

[Implemented] PB4.30 : UseGadgetList( #PB_ActiveGadgetList )

Posted: Sat Sep 20, 2008 7:31 pm
by eddy
I notice some tips use a temporary window.
And now each temporary window creates a new gadgetlist.

This constant could be usefull to restore the currrent gadget list.


#PB_ActiveGadgetList = 0 : to get the active gadgetlist (zero if no active gadgetlist)

Code: Select all

GadgetListToRestore=UseGadgetList( #PB_ActiveGadgetList )

....

UseGadgetList( GadgetListToRestore )

Posted: Sun Sep 21, 2008 11:44 am
by srod
Yes, either that or a flag/style added to OpenWindow() to prevent the automatic creation of a new gadgetlist. This automatic creation is good for general applications; but not so good when creating libraries which should not be altering any settings within the host application etc.

This was discussed in the alpha-testing stage and indeed it was your splitter control which first highlighted this problem for me. I wondered when you'd notice it? :wink:

I then encountered the problem in my own code and had to switch to use api to create a window to prevent the current gadget list being reset. As stated above, when creating libraries we do not want to be messing around with settings in the main host application which is why I have requested some means of preventing the gadgetlist being reset or being able to reset it manually as you have suggested.

In short : +1. :)

Posted: Sun Sep 21, 2008 5:15 pm
by eddy
exactly ... All my libraries were broken. 8)

Posted: Wed Oct 22, 2008 10:26 pm
by freak
Changed the following for beta4:
- added #PB_Window_NoGadgets for OpenWindow()
- UseGadgetList() returns the previous gadgetlist window handle
- UseGadgetList() can restore the complete gadget stack (panel/containergadgets). Before, the stack was always reset.
- UseGadgetList(0) changes nothing and returns the current gadget window


Will work like this:

Code: Select all

  If OpenWindow(0, 0, 0, 500, 500, "Main Window", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
    ButtonGadget(0, 10, 10, 150, 25, "Button 1")
    
    ; Create Window with #PB_Window_NoGadgets to prevent automatic GadgetList creation
    If OpenWindow(1, 0, 0, 300, 200, "Child Window", #PB_Window_TitleBar|#PB_Window_WindowCentered|#PB_Window_NoGadgets, WindowID(0))     
      OldGadgetList = UseGadgetList(WindowID(1)) ; Create GadgetList and store old GadgetList
      
      ButtonGadget(10, 10, 10, 150, 25, "Child Window Button")
      
      UseGadgetList(OldGadgetList)               ; Return to previous GadgetList
    EndIf
    
    ButtonGadget(1, 10, 45, 150, 25, "Button 2") ; This will be on the main window again
    
    Repeat
    Until WaitWindowEvent() = #PB_Event_CloseWindow
  EndIf

Posted: Wed Oct 22, 2008 10:36 pm
by srod
Excellent. Thanks. :)

Posted: Wed Oct 22, 2008 10:40 pm
by eddy
Excellent :P