* adapted from GetParent()
Code: Select all
;========================================================
; GadgetListWindow() returns the window number of the
; current gadget list obtained from UseGadgetList(0)
;
; Windows only
;
; tested & working on Win 8.1 with PureBasic v5.40 (x64)
;
; by TI-994A - free to use, improve, share...
;
; 14th January 2016
;========================================================
Procedure GadgetListWindow()
;usig the UseGadgetList(0) function, the
;GetProp_() function translates the returned
;PureBasic window ID to its window number
w = GetProp_(UseGadgetList(0),
StringField("PB_WINDOWID", 1, ",")) - 1
ProcedureReturn w
EndProcedure
OpenWindow(0, 100, 100, 200, 100, "Window 0")
ButtonGadget(0, 10, 20, 100, 30, "Button")
OpenWindow(1, 200, 200, 200, 100, "Window 1")
ButtonGadget(1, 10, 20, 100, 30, "Button")
OpenWindow(2, 300, 300, 200, 100, "Window 2")
ButtonGadget(2, 10, 20, 100, 30, "Button")
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
appQuit = 1
Case #PB_Event_Gadget
;for this example, when a button is pressed,
;its window is made the current gadget list
UseGadgetList(WindowID(EventWindow()))
MessageRequester("UseGadgetList()",
"Current gadget list: Window #" +
Str(GadgetListWindow()))
EndSelect
Until appQuit = 1
