I have an application where users can minimize it to the systray. I
would like when the user restores the application from the systray to
return to the previous forms size.

If the form was maximized when minimized and I use the following code

this.WindowState = FormWindowState.Normal ;

the form is not resized back to its previous maximized state.

I figured I could grab the location and size of the form prior to
minimizing using
formXLocation = this.Location.X;
formYLocation = this.Location.Y;
formSizeWidth = this.Size.Width;
formSizeHeight = this.Size.Height;

However, I am not sure exactly how to force the form back to those
sizes since you can't call
this.Location.X = ... since Location.X is not a variable.

Thanks,
Amy

Re: Restore Form To Previous Size by Marc

Marc
Mon Jun 12 11:23:07 CDT 2006

Rether than restoring to "normal", just store the old FormWindowState and
put that back (i.e. go back to maximised if you were previously maximised);
you might find that fixes it.
Alternatively, rather than storing x,y pairs and width, height pairs, store
the Point and Size values; the Location and Size properties are settable.

Marc



Re: Restore Form To Previous Size by amyl

amyl
Mon Jun 12 13:03:42 CDT 2006


Marc Gravell wrote:
> Rether than restoring to "normal", just store the old FormWindowState and
> put that back (i.e. go back to maximised if you were previously maximised);

Thanks Marc - sotring the old windowstate did the trick.

Amy.


Re: Restore Form To Previous Size by Herfried

Herfried
Mon Jun 12 13:09:29 CDT 2006

<amyl@paxemail.com> schrieb:
> However, I am not sure exactly how to force the form back to those
> sizes since you can't call
> this.Location.X = ... since Location.X is not a variable.

\\\
this.Location = new Point(..., ...);
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>