Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the Form.DesktopBounds from before the window was minimized or maximized

Tags:

c#

.net

winforms

I would like to save and restore the state of a WinForms Form, more specifically the DesktopBounds and the WindowState.

However, when the WindowState is not normal (i.e. minimized or maximized) then I would like to save the previous value of DesktopBounds, when the Form was still in a normal state.

Obviously, windows remembers this previous state somewhere, because clicking the maximize button twice restores the original position and size of the form. How do I read this original state?

EDIT: Some similar SO questions:

  • How to make a form remember its Bounds and WindowState (Taking dual monitor setups into account).
  • How to record window position in WinForms application settings.
  • Restoring Window Size/Position With Multiple Monitors.
  • Save and Restore Form Position and Size.
like image 523
Wim Coenen Avatar asked Oct 27 '09 14:10

Wim Coenen


1 Answers

Check RestoreBounds property.

like image 94
Josip Medved Avatar answered Oct 06 '22 00:10

Josip Medved