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

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
eddy
Addict
Addict
Posts: 1479
Joined: Mon May 26, 2003 3:07 pm
Location: Nantes

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

Post 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 )
Last edited by eddy on Sun Sep 21, 2008 3:45 pm, edited 1 time in total.
Imagewin10 x64 5.72 | IDE | PB plugin | Tools | Sprite | JSON | visual tool
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post 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. :)
I may look like a mule, but I'm not a complete ass.
User avatar
eddy
Addict
Addict
Posts: 1479
Joined: Mon May 26, 2003 3:07 pm
Location: Nantes

Post by eddy »

exactly ... All my libraries were broken. 8)
Imagewin10 x64 5.72 | IDE | PB plugin | Tools | Sprite | JSON | visual tool
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post 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
quidquid Latine dictum sit altum videtur
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Excellent. Thanks. :)
I may look like a mule, but I'm not a complete ass.
User avatar
eddy
Addict
Addict
Posts: 1479
Joined: Mon May 26, 2003 3:07 pm
Location: Nantes

Post by eddy »

Excellent :P
Imagewin10 x64 5.72 | IDE | PB plugin | Tools | Sprite | JSON | visual tool
Post Reply