Minimize Child Windows with Parent

Xojo using more or less the CPU is not important…!!!
Perhaps if my electricity bill increasing because of Xojo i may send the electricity bill to Xojo Developers. Ha ha i am joking…!!!

Please everyone see my attached file and help me where is the error.
I try over a month to minimize main window and also floating windows without success as at restore do not restore all opened floating windows…
I am hopeless and seeking real help.!!!

@nektarios_borbilas

I suggest you create a new post with your question, because it’s not related with the current question. And at the same time add some more information about you issue because you will be asked for more details.

Thanks

2 Likes

Add one line of code as last line to the “Pressed” event of the Button1 in Window1:

childWindows.Add(wnd)

To minimize Window1 and all of its floating child windows: change the “Minimized” event of Window1 to

For Each win As DesktopWindow In childWindows
  win.Minimize
Next

Add a “Restored” event to Window1:

For Each win As DesktopWindow In childWindows
  win.Restore
Next

But maybe there are some windows that are minimized intentionally.
In that case the app should only restore the windows that weren’t minimized.

These states could be stored in a window property or a global array, that holds references to the minimized windows.
The problem might be that a window can be minimized by the user, or in the Minimized event of the main window. So, it needs a bit more care to distinguish those two conditions.

Did you have a look at his example project? childWindows() is such an Array of DesktopWindows.
Yes, there are more cases to take care of, but question was how to minimize/maximize all floating windows with their parent window…

Thank you very much for your valuable time and posting a solution.
Please verify the code you provided by adding it to the project i uploaded as i get various errors…
Floating windows are a serious problem that should be solved by developers. I keep trying to find a solution for floating windows instead of trying to finish my project (an ordering program for windows items,customers,orders etc…). I want my program to be as much as perfect it could be. If i do not find a solution i cannot go further…

I’ve used your project to build the code :wink:
Forgot the write that I commented out all of your code in the “Minimized” event of Window1.

What error messages do you get?

Hi again
in the press event i wrote your code:

childWindows.Add(wnd)

and i get error:

Window1.Button1.Pressed, line 1
This item does not exist
childWindows.Add(wnd)

i also have comment my code in minimize event of window1 and i wrote your code:

> For Each win As DesktopWindow In childWindows
>   win.Minimize
> Next

and got error:

Window1.Minimized, line 6
This item does not exist
For Each win As DesktopWindow In childWindows

and this is the error for restore event of window1

Window1.Restored, line 1
This item does not exist
For Each win As DesktopWindow In childWindows

You have to add that line as last line, after your code in the “Pressed” event, so the whole code looks like this:

Dim wnd As New Window2

Dim n As Integer
n = App.WindowCount
wnd.Left = Me.Top + 30 * n
wnd.Left = Me.Left + 30 * n
wnd.Show

childWindows.Add(wnd)

ChildWindows() is a property in your MyWindow subclass.

But maybe its easier to have a look at the changes I made to your project: Floating_windows

i’ve made my test on a Mac and all Floating windows (I did test with three and four) got minimized and restored. Will try it tomorrow on Windows 10 - but behaviour should be the same as on Mac…

Your code to move the Floating windows is not really ready, currently you place them staggered, without regarding any user interaction, like moving a Floating window to another place.

1 Like

Hi.
All Work Fine now.!!!
I had to add paint event to the main window1 and display all child windows.
i upload the project to help community if they may face the same problem as i did.

Many many thanks for your precious help.!!!