Parent and child window

Hi,

Assuming that there are 2 windows, 1 is a parent and the other is a child.
When the parent window is minimized, the child one should be minimized as well.

With a Document type of window and floating, the child one remains up when parent is minimized.

Thanks.

That is the correct beahvior. Windows set to “Document” are independent of others. Same for “Floating” windows. So you need to minimize the second window yourself. This should work (not tested):

[code]Event Window1.Minimize()
Window2.Minimize()
End

Event Window1.Restore()
Window2.Restore()
End[/code]
On OS X you can do the following instead of the above:

[code]Declare Sub addChildWindow Lib “Cocoa” Selector “addChildWindow:ordered:” (parentWindow As Ptr, childWindow As Ptr, orderingMode As Integer)

Const NSWindowBelow = -1

Dim win2 As New Window2()
win2.Show()

addChildWindow(Ptr(Self.Handle), Ptr(win2.Handle), NSWindowBelow)[/code]
This will create a true child window, which will be minimized and restored automatically with the parent window. Also when minimized only the parent window will be shown in the Dock when you right-click.

Great. Now I understand how it works.

There are 20 windows in Application, and I think I could write a code something like this in main windows’s minimize event.

Windows1.Minimize
Windows2.Minimize
Windows3.Minimize

However, below code can find the ‘opened’ window and call Minimize event for other windows, so trying to code it.
Do you think there is any drawback?

For i As Integer = 0 To WindowCount - 1
Dim w As Window = Window(i)
w.Minimize
Next

I’m not sure if calling Minimize on the main window which is already minimizing is good, so maybe exclude it in the loop:

For i As Integer = 0 To WindowCount - 1 Dim w As Window = Window(i) If w <> Self Then w.Minimize End Next

Good point. Thank you!