Get the parent window (cross platform)
Get the parent window (cross platform)
Last edited by mestnyi on Thu Mar 03, 2022 7:11 pm, edited 1 time in total.
Re: Get the parent window (cross platform)
Code: Select all
Debug UseGadgetList(0)PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

Re: Get the parent window (cross platform)
^
Last edited by mestnyi on Thu Mar 03, 2022 7:14 pm, edited 1 time in total.
- netmaestro
- PureBasic Bullfrog

- Posts: 8452
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Re: Get the parent window (cross platform)
if you call this procedure right after you create a gadget, it will return the root window it was created on regardless of how deep it is. Then you can store it for future use. I can't come up with a crossplatform way to pass a gadget# to the procedure.
Code: Select all
Procedure GetRootWindow()
savedgadgetlist = UseGadgetList(0)
result = savedgadgetlist
While (result<>lastresult) And result<>0
result=UseGadgetList(result)
If result
lastresult=result
EndIf
Wend
UseGadgetList(savedgadgetlist)
ProcedureReturn lastresult
EndProcedure
BERESHEIT
Re: Get the parent window (cross platform)
^
Last edited by mestnyi on Thu Mar 03, 2022 7:12 pm, edited 1 time in total.
Re: Get the parent window (cross platform)
^
Last edited by mestnyi on Thu Mar 03, 2022 7:13 pm, edited 1 time in total.
Re: Get the parent window (cross platform)
I think he means : How to get the PB Object number crossplatform.... from a windows-handle ... to use e.g. PostEvent()
Re: Get the parent window (cross platform)
I saw your question yesterday, but my englisch is not so good and ts-soft was quicker as i with a other interpretation of you question.
today i am again unsure. it is too simple, but may ...
today i am again unsure. it is too simple, but may ...
Code: Select all
OpenWindow(1, 100, 200, 200, 100, "Window 1")
ButtonGadget (101, 10, 10, 180, 20, "Hello")
ButtonGadget (102, 10, 40, 180, 20, "World")
OpenWindow(2, 310, 200, 200, 100, "Window 2")
ButtonGadget (201, 10, 10, 180, 20, "Hello")
ButtonGadget (202, 10, 40, 180, 20, "World")
UseGadgetList(WindowID(1))
ButtonGadget (103, 10, 70, 180, 20, "!")
UseGadgetList(WindowID(2))
ButtonGadget (203, 10, 70, 180, 20, "?")
Repeat
Event = WaitWindowEvent()
If Event = #PB_Event_Gadget : GadgetEvent = EventGadget()
If GadgetEvent > 200 : Debug WindowID(2) : ElseIf GadgetEvent > 100 : Debug WindowID(1) : EndIf
EndIf
Until Event = #PB_Event_CloseWindowPlease pardon my English, my native tongue is German.
Re: Get the parent window (cross platform)
^
Last edited by mestnyi on Thu Mar 03, 2022 7:12 pm, edited 1 time in total.
Re: Get the parent window (cross platform)
Code: Select all
ExamineDesktops()
OpenWindow(1, 100, 200, 200, 100, "Window 1")
ButtonGadget (1, 10, 10, 180, 20, "1")
SetGadgetData(1,1)
ButtonGadget (2, 10, 40, 180, 20, "2")
SetGadgetData(2,1)
OpenWindow(2, 310, 200, 200, 100, "Window 2")
ButtonGadget (3, 10, 10, 180, 20, "3")
SetGadgetData(3,2)
ButtonGadget (4, 10, 40, 180, 20, "4")
SetGadgetData(4,2)
UseGadgetList(WindowID(1))
ButtonGadget (5, 10, 70, 180, 20, "5")
SetGadgetData(5,1)
UseGadgetList(WindowID(2))
ButtonGadget (6, 10, 70, 180, 20, "6")
SetGadgetData(6,2)
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Quit = 1
Case #PB_Event_Gadget
Select EventGadget()
Case 1
EndSelect
Default
x = DesktopMouseX()
y = DesktopMouseY()
For g = 1 To 6
If x >= GadgetX(g,#PB_Gadget_ScreenCoordinate) And x < GadgetX(g,#PB_Gadget_ScreenCoordinate) + GadgetWidth(g) And y >= GadgetY(g,#PB_Gadget_ScreenCoordinate) And y < GadgetY(g,#PB_Gadget_ScreenCoordinate) + GadgetHeight(g)
If g <> oldg
Debug "Parent Window is : Window "+Str(GetGadgetData(g))
oldg = g
EndIf
; MessageRequester("Info","Parent Window is : Window "+Str(GetGadgetData(g)),#PB_MessageRequester_Ok)
EndIf
Next
EndSelect
Until Quit = 1
End
Egypt my love
-
IdeasVacuum
- Always Here

- Posts: 6426
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: Get the parent window (cross platform)
That is something worth knowing - I always thought SetGadgetData() was Windows only. It is certainly very handy for this purpose, as Rashad has shown.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.

