Public Class Form1
Private _previousWindowState As FormWindowState = FormWindowState.Normal
Private Sub Form1_Resize(sender As Object, e As EventArgs) Handles Me.Resize
If _previousWindowState <> FormWindowState.Minimized AndAlso Me.WindowState = FormWindowState.Minimized Then
For Each child As Form In Me.OwnedForms
child.Tag = child.WindowState
Next
ElseIf _previousWindowState = FormWindowState.Minimized AndAlso Me.WindowState <> FormWindowState.Minimized Then
Me.BeginInvoke(New Threading.ThreadStart(AddressOf FixChildren))
End If
_previousWindowState = Me.WindowState
End Sub
Private Sub FixChildren()
For Each child As Form In Me.OwnedForms
child.WindowState = CType(child.Tag, FormWindowState)
Next
End Sub
End Class
restoring owned children forms to the same state when the owner was minimized
-
12-07-2023 - |
Question
This sounds so simple that it may already been asked, but I could not find the same question (sorry if it's there).
I have a form ("owner") maximized with various "owned" children (smaller) forms which are either minimized or in "normal" state.
If I minimize the (owner) form and then restore it to its initial window state (maximized), I can see that all the owned children also get (strangely) automatically to a "normal" window state.
Instead I want to keep them the same way as I left them when I minimized the owner form, because this is just what a user would expect.
How do I correct this behavior. Is there any settings at design time to avoid that ? (Any example/help in either c# or vb.net would be great.)
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow