Page 1 of 1

Window in a window

Posted: Tue Nov 22, 2022 10:17 am
by lesserpanda
Hi guys, I have a few questions and tried searching it up in the forum.

1. How do I openWindow (parent) and then have all the child inside the parent window and maximize/minimize accordingly? The current open window seems to allow the child window to roam freely outside the boundaries of the parent window.
2. Is there a way to make a form in the IDE and then make that as a template? I guess you can call it multiple times openwindow and it should just take it as it is.
3. OK then how do I reference that particular window and then create gadgets dynamically in there specifically for that opened window?

Thanks. And apologies if it's somewhere in the forums already.

Re: Window in a window

Posted: Tue Nov 22, 2022 11:40 am
by STARGÅTE
Do you mean the MDI Gadget:

Code: Select all

Enumeration
	#Window_Main
	#Window_Child1
	#Window_Child2
EndEnumeration

Enumeration
	#Menu_Main
EndEnumeration

Enumeration
	#Gadget_ChildWindows
EndEnumeration

OpenWindow(#Window_Main, 0, 0, 400, 300, "MDIGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_SizeGadget | #PB_Window_MaximizeGadget)
CreateMenu(#Menu_Main, WindowID(#Window_Main))
	MenuTitle("Child Windows")
MDIGadget(#Gadget_ChildWindows, 0, 0, 0, 0, 0, 0, #PB_MDI_AutoSize)
	AddGadgetItem(#Gadget_ChildWindows, #Window_Child1, "child window 1")
	AddGadgetItem(#Gadget_ChildWindows, #Window_Child2, "child window 2")

Repeat 
Until WaitWindowEvent() = #PB_Event_CloseWindow

Re: Window in a window

Posted: Tue Nov 22, 2022 11:52 pm
by lesserpanda
Hi thanks for the reply. Tried the code out and yes, the child windows were created. I tried to put a button on a specific child but I think I got it wrong. What I did was below but it kinda overwrote the children.

Code: Select all

UseGadgetList(WindowID(#Window_Child2))
ButtonGadget(#Button1, 10, 10, 150, 25, "Child Window Button")
STARGÅTE wrote: Tue Nov 22, 2022 11:40 am Do you mean the MDI Gadget:

Code: Select all

Enumeration
	#Window_Main
	#Window_Child1
	#Window_Child2
EndEnumeration

Enumeration
	#Menu_Main
EndEnumeration

Enumeration
	#Gadget_ChildWindows
EndEnumeration

OpenWindow(#Window_Main, 0, 0, 400, 300, "MDIGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_SizeGadget | #PB_Window_MaximizeGadget)
CreateMenu(#Menu_Main, WindowID(#Window_Main))
	MenuTitle("Child Windows")
MDIGadget(#Gadget_ChildWindows, 0, 0, 0, 0, 0, 0, #PB_MDI_AutoSize)
	AddGadgetItem(#Gadget_ChildWindows, #Window_Child1, "child window 1")
	AddGadgetItem(#Gadget_ChildWindows, #Window_Child2, "child window 2")

Repeat 
Until WaitWindowEvent() = #PB_Event_CloseWindow

Re: Window in a window

Posted: Wed Nov 23, 2022 6:48 am
by STARGÅTE

Code: Select all

Enumeration
	#Window_Main
	#Window_Child1
	#Window_Child2
EndEnumeration

Enumeration
	#Menu_Main
EndEnumeration

Enumeration
	#Gadget_ChildWindows
	#Button1
	#Button2
EndEnumeration

OpenWindow(#Window_Main, 0, 0, 400, 300, "MDIGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_SizeGadget | #PB_Window_MaximizeGadget)
CreateMenu(#Menu_Main, WindowID(#Window_Main))
	MenuTitle("Child Windows")
MDIGadget(#Gadget_ChildWindows, 0, 0, 0, 0, 0, 0, #PB_MDI_AutoSize)
	AddGadgetItem(#Gadget_ChildWindows, #Window_Child1, "child window 1")
	AddGadgetItem(#Gadget_ChildWindows, #Window_Child2, "child window 2")

UseGadgetList(WindowID(#Window_Child1))
	ButtonGadget(#Button1, 10, 10, 150, 25, "Child Window Button")

UseGadgetList(WindowID(#Window_Child2))
	ButtonGadget(#Button2, 10, 10, 150, 25, "Child Window Button")

Repeat 
Until WaitWindowEvent() = #PB_Event_CloseWindow

Re: Window in a window

Posted: Wed Nov 23, 2022 11:45 pm
by lesserpanda
Thank you for your patience and example code. Appreciate it.

Re: Window in a window

Posted: Sun Dec 25, 2022 6:05 am
by jchase1970
Is there a way to use #PB_Event_CloseWindow to close a child window and not close all the windows?

Re: Window in a window

Posted: Sun Dec 25, 2022 8:27 am
by nsstudios
Happy holidays!

You can use EventWindow() to see which window an event belongs to.

Code: Select all

Enumeration
	#Window_Main
	#Window_Child1
	#Window_Child2
EndEnumeration

Enumeration
	#Menu_Main
EndEnumeration

Enumeration
	#Gadget_ChildWindows
	#Button1
	#Button2
EndEnumeration

OpenWindow(#Window_Main, 0, 0, 400, 300, "MDIGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_SizeGadget | #PB_Window_MaximizeGadget)
CreateMenu(#Menu_Main, WindowID(#Window_Main))
	MenuTitle("Child Windows")
MDIGadget(#Gadget_ChildWindows, 0, 0, 0, 0, 0, 0, #PB_MDI_AutoSize)
	AddGadgetItem(#Gadget_ChildWindows, #Window_Child1, "child window 1")
	AddGadgetItem(#Gadget_ChildWindows, #Window_Child2, "child window 2")

UseGadgetList(WindowID(#Window_Child1))
	ButtonGadget(#Button1, 10, 10, 150, 25, "Child Window Button")

UseGadgetList(WindowID(#Window_Child2))
	ButtonGadget(#Button2, 10, 10, 150, 25, "Child Window Button")

Repeat 
e=WaitWindowEvent()
If e<>#PB_Event_CloseWindow
Continue
EndIf
w=EventWindow()
If w=#Window_Main
End
EndIf
CloseWindow(w)
ForEver
If you want child windows to be closeable with the close event, then you can just do

Code: Select all

e=WaitWindowEvent()
If e<>#PB_Event_CloseWindow
Continue
EndIf
w=GetGadgetState(#Gadget_ChildWindows)
If w=-1; no child windows focused, assume the main one
End
EndIf
CloseWindow(w)
ForEver