Home All Groups Group Topic Archive Search About

Restore Form to Prior State

Author
26 May 2005 1:21 AM
AGP
Im trying to rstore a form to its prior state.
If you minimize a form and then right click on it in the
taskbar then there is a menu item labeled "Restore".
That is what i want to emulate.

Note that simply using me.windowstate = vbnormal
will not work as I want. i want to restore the form as
it was before it got minimized. So it may be maximized
or just normal.

I just cant figure out how to do it.

tia
AGP

Author
26 May 2005 2:40 AM
Michael Cole
AGP wrote:
> Im trying to rstore a form to its prior state.
> If you minimize a form and then right click on it in the
> taskbar then there is a menu item labeled "Restore".
> That is what i want to emulate.
>
> Note that simply using me.windowstate = vbnormal
> will not work as I want. i want to restore the form as
> it was before it got minimized. So it may be maximized
> or just normal.
>
> I just cant figure out how to do it.

Save the previous WindowState, and then set it back to that in the Restore
action.

--
Regards,

Michael Cole
Author
26 May 2005 2:52 AM
AGP
OK forgot to mention that...but I have already tried that...
in what event shall I save the state...the Form_Resize happens
after the form has been changed so I cant save the prior state.
I need an event that happens before the form is changed.

AGP

Show quoteHide quote
"Michael Cole" <no***@hansen.com> wrote in message
news:u3iuUxZYFHA.3280@TK2MSFTNGP09.phx.gbl...
> AGP wrote:
> > Im trying to rstore a form to its prior state.
> > If you minimize a form and then right click on it in the
> > taskbar then there is a menu item labeled "Restore".
> > That is what i want to emulate.
> >
> > Note that simply using me.windowstate = vbnormal
> > will not work as I want. i want to restore the form as
> > it was before it got minimized. So it may be maximized
> > or just normal.
> >
> > I just cant figure out how to do it.
>
> Save the previous WindowState, and then set it back to that in the Restore
> action.
>
> --
> Regards,
>
> Michael Cole
>
>
Author
26 May 2005 3:08 AM
Tom Esh
On Thu, 26 May 2005 02:52:48 GMT, "AGP" <sindizzy.***@softhome.net>
wrote:

>OK forgot to mention that...but I have already tried that...
>in what event shall I save the state...the Form_Resize happens
>after the form has been changed so I cant save the prior state.
>I need an event that happens before the form is changed.

Simplest way is to use ShowWindow with SW_RESTORE:

'declares...
Private Const SW_RESTORE = 9
Private Declare Function ShowWindow Lib "user32" _
    (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long

'usage...
ShowWindow Me.hWnd, SW_RESTORE


-Tom
MVP - Visual Basic
(please post replies to the newsgroup)
Author
26 May 2005 4:21 AM
Jeff Johnson [MVP: VB]
"Tom Esh" <tjeshGibber***@suscom.net> wrote in message
news:69fa915p38gjt013nbed9ge1uhddc54qqt@4ax.com...

> Simplest way is to use ShowWindow with SW_RESTORE:

ShowWindow()! Yeah, that's right. I was going to send him the long way with
a WM_SYSCOMMAND message....
Author
26 May 2005 7:02 AM
Tom Esh
On Thu, 26 May 2005 00:21:06 -0400, "Jeff Johnson [MVP: VB]"
<i.get@enough.spam> wrote:

>ShowWindow()! Yeah, that's right. I was going to send him the long way with
>a WM_SYSCOMMAND message....

Yup, plus it has the side benefit of working even when the form's
ControlBox prop is False. (Some syscommands don't unless you hack
around it by removing the sysmenu at runtime with the Api.)


-Tom
MVP - Visual Basic
(please post replies to the newsgroup)
Author
26 May 2005 11:45 PM
AGP
That is exactly what i was looking for.
It works. Thanks!!!!
AGP

Show quoteHide quote
"Tom Esh" <tjeshGibber***@suscom.net> wrote in message
news:69fa915p38gjt013nbed9ge1uhddc54qqt@4ax.com...
> On Thu, 26 May 2005 02:52:48 GMT, "AGP" <sindizzy.***@softhome.net>
> wrote:
>
> >OK forgot to mention that...but I have already tried that...
> >in what event shall I save the state...the Form_Resize happens
> >after the form has been changed so I cant save the prior state.
> >I need an event that happens before the form is changed.
>
> Simplest way is to use ShowWindow with SW_RESTORE:
>
> 'declares...
> Private Const SW_RESTORE = 9
> Private Declare Function ShowWindow Lib "user32" _
> (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long
>
> 'usage...
> ShowWindow Me.hWnd, SW_RESTORE
>
>
> -Tom
> MVP - Visual Basic
> (please post replies to the newsgroup)