Minimize Maximize - Where is normal state's size and location?

JumpyNET

Centurion
Joined
Apr 4, 2005
Messages
196
When a form is minimized or maximized the size and location properties change. But where are the normal state's size and location stored in the meantime?

Or is some event fired when the user minimizes or maximizes the form?

I'm actually trying to save the form state of my main form on program end and restore the size and location on program start.
 
This article talks about a RestoreBounds method. I cannot find this within my .Net environment, so I'm going to go ahead and assume its .Net 2.0 exclusive. If your using .Net 2.0 then check out the article. If your not, I would do it as follows.

If I remember correctly from your other post your working in VB. So here goes...
Visual Basic:
' have these two public variables
Public m_Size as Size
Public m_State as FormWindowState
'
' in your resize event
If WindowState = FormWindowState.Normal Then
    ' the form isn't maximised or minimised so store the new size
    m_Size = Size
End If
'
' store the state so you can restore the application minimised
m_state = WindowState
 
I really want to stay away from "My.Settings" and rather save my settings to a simple text file.

For know I'll settle for the resize event, but I'm still open for better ways in case someone comes across one.¨

PS: You have been very active today Cags. :D Thanks a lot!!
 
Last edited:
Note the MaximizedBounds and RestoreBounds properties. These set/return the bounds that the form will assume in the respective state, regardless of the current state.
 
marble_eater said:
Note the MaximizedBounds and RestoreBounds properties. These set/return the bounds that the form will assume in the respective state, regardless of the current state.

Thank you! :D That is exactly what I was looking for.
 
Back
Top