Cant Minimize window after Maximized

Hey all,

As the title says, I cant seem to figure out how to minimize a window after maximized. I am using a Plain Box window with all Min, Max and Close buttons disabled. I have a temporary Pushbutton as a maximize and minimize control (Changing it to a custom Canvas button at a later date).

within the Buttons Action event I have

Window1.Maximize()
Window1.Minimize()

I know Window1.maximize() works on its own. but how do i add Minimize to the event? ive tried the above and If statement…

If Window1.Maximize() then
Window1.Minimize()
Else
Window1.Maximize()
End if

I know I’m doing this wrong but could someone point me in the right direction?

You should call one of those methods at a time, not both.

Looking at your code:

If Window1.Maximize() then
    Window1.Minimize()
Else
    Window1.Maximize()
End if

Effectively what you are getting here is a call to Maximize followed quickly by a call to minimize. It doesn’t surprise me that doesn’t work.

Just out of curiosity, why are you disabling the system controls?

Thank you for the reply Greg.

I disabled the controls to create a custom window with my own canvas controls in place of the stock windows ones.

at the moment I am using a pushbutton until I get onto photoshop and draw a new button for the canvas control.

If you ultimately want to minimise the window, why are you maximising it first?

I think Robin wants to know if the window is maximized then minimize it. If it is not maximized then maximize it.

1 Like

Ah, ok, a three-steps process (if normal, maximise, if maximised, minimise).
Now, I seem to remember you can’t minimise directly a maximised window under Windows (you’d have to restore it first). I’m really not sure, as the last time I did “intensive” programming under Windows was around 15 years ago.

Perhaps try to restore it (un-maximise it) before minimising it?

First off, by ‘minimize’ are you trying to minimize the window to the taskbar or are you trying to restore it from fullscreen to it’s previous size? Either way, you should probably set a variable to remember the actual state of the window. Something like the following will maximize and restore the window.

Static fs As Boolean = False
If fs Then
  Window1.Restore
  fs = False
Else
  Window1.Maximize
  fs = True
End If

The static Boolean could be a global if you want.

3 Likes