views:

36

answers:

1

Hi stack overflow,

I have a little problem where if I have a WinForm and maximize it, and send it to the system tray, when I restore it, it isn't the maximum size any longer.

I'm trying to set a flag IsMaximized to true if the form is maximized when it is sent to the tray, but when it is being sent to the tray, the form state is minimized, so it doesn't catch when it is maximized.

Any thoughts on how I can work around this?

Thanks!

+1  A: 

Try this:

if (this.WindowState == FormWindowState.Maximized)
{  
    if (this.Size != this.MaximumSize)  
    {  
        this.Size = this.MaximumSize;  
        this.WindwoState = FormWindowState.Maximized;
    }  
} 
Wildhorn
This works, except for some reason, whenever the form is restored from the system tray, it is not visible until you click it in the taskbar. Any ideas on how to fix this?
Soo
I think it is due that it doesnt know it is now maximized, soadd this.WindwoState = FormWindowState.Maximized;I edited my answer with it
Wildhorn
@Wildhorn, I'm still getting the same problem with the new code... This is pretty confusing.
Soo
I have no idea then. Try a this.Show(); Btw, dont forget to accept it as an answer if it fixed your main problem ;)
Wildhorn