The ParentID Flag in Openwindow doesn't do this.
I have to use the Windows API SetParent() and after that it works!
The Questions:
1. Is there a PB only way to do this?
2. If not, how to do this on other OS Mac an Linux?
Here my sample code
Code: Select all
EnableExplicit
Define wndFlags
Define x,y,w,h
Enumeration Windows
#wnd_Main
#wnd_Child1
#wnd_Child2
#wnd_Child2_Child
EndEnumeration
ExamineDesktops()
h = DesktopHeight(0) : w = DesktopWidth(0)
h= h/2
w = w/2
x=0 : y=0
wndFlags = #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered
If OpenWindow(#wnd_Main, x, y, w, h, "MainWindow", wndFlags)
x= WindowX(#wnd_Main, #PB_Window_InnerCoordinate)
y= WindowY(#wnd_Main, #PB_Window_InnerCoordinate)
w= WindowWidth(#wnd_Main, #PB_Window_InnerCoordinate)
h= WindowHeight(#wnd_Main, #PB_Window_InnerCoordinate)
wndFlags = #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget
If OpenWindow(#wnd_Child1,10,20,w/3,h/3, "Child Window 1", wndFlags, WindowID(#wnd_Main))
Debug "ChildWindow"
Debug "x = " + WindowX(#wnd_Child1)
Debug "y = " + WindowY(#wnd_Child1)
SetParent_(WindowID(#wnd_Child1), WindowID(#wnd_Main)) ; !!! Is there a PureBasic way without WinAPI
EndIf
x= WindowX(#wnd_Child1, #PB_Window_FrameCoordinate)
y= WindowY(#wnd_Child1, #PB_Window_FrameCoordinate)
w= WindowWidth(#wnd_Child1, #PB_Window_InnerCoordinate)
h= WindowHeight(#wnd_Child1, #PB_Window_InnerCoordinate)
If OpenWindow(#wnd_Child2,w+40,20,w,h, "Child Window 2", wndFlags, WindowID(#wnd_Main))
Debug "ChildWindow"
Debug "x = " + WindowX(#wnd_Child1)
Debug "y = " + WindowY(#wnd_Child1)
SetParent_(WindowID(#wnd_Child2), WindowID(#wnd_Main))
x= WindowX(#wnd_Child2, #PB_Window_InnerCoordinate)
y= WindowY(#wnd_Child2, #PB_Window_InnerCoordinate)
w= WindowWidth(#wnd_Child2, #PB_Window_InnerCoordinate)
h= WindowHeight(#wnd_Child2, #PB_Window_InnerCoordinate)
If OpenWindow(#wnd_Child2_Child, 0, 0,w/2,h/2, "Child of Child 2", wndFlags, WindowID(#wnd_Child2))
Debug "ChildWindow"
Debug "x = " + WindowX(#wnd_Child2)
Debug "y = " + WindowY(#wnd_Child2)
SetParent_(WindowID(#wnd_Child2_Child), WindowID(#wnd_Child2))
EndIf
EndIf
EndIf
Define Event, Quit
Repeat
Event = WaitWindowEvent()
Select EventWindow()
Case #wnd_Child1
If Event = #PB_Event_CloseWindow ; If the user has pressed on the close button
CloseWindow(#wnd_Child1)
EndIf
Case #wnd_Child2
If Event = #PB_Event_CloseWindow ; If the user has pressed on the close button
CloseWindow(#wnd_Child2)
EndIf
Case #wnd_Child2_Child
If Event = #PB_Event_CloseWindow ; If the user has pressed on the close button
CloseWindow(#wnd_Child2_Child)
EndIf
Case #wnd_Main
If Event = #PB_Event_CloseWindow ; If the user has pressed on the close button
Quit = #True
EndIf
EndSelect
Until Quit = #True



