SAMPLE: Save and Restore Window Size, Position, Sample Code

Last reviewed: April 7, 1997
Article ID: Q83234
3.10 WINDOWS kbprg kbfile

The information in this article applies to:

  • Microsoft Windows Software Development Kit (SDK) for Windows versions 3.0 and 3.1

Many applications available today allow the user to store the size and position of the application's main window in an initialization file. The next time the user runs the application, the stored size and position information is used to create the main window. The Windows File Manager and Program Manager are examples of applications that save and restore size and position information.

Under Windows 3.0, many operations are required to retrieve the normal size and position for a window if it is maximized or minimized. Under Windows 3.1, the GetWindowPlacement() function has been provided to perform this task. GetWindowPlacement() provides the size and position of a restored window at all times, even when the window is minimized or maximized. The SetWindowPlacement() function allows an application to change its restored size and position at all times.

The GetWindowPlacement() function stores the following information regarding a specified window into a WINDOWPLACEMENT structure:

  • Its current state (maximized, minimized or normal)
  • Its maximized position
  • Its minimized position
  • The rectangle that the window occupies in its normal position

The SetWindowPlacement() function restores a specified window to the state described by a WINDOWPLACEMENT structure.

MDIREST is a file in the Microsoft Software Library that demonstrates using GetWindowPlacement() to save the state of all windows in a multiple document interface (MDI) application when the application shuts down. When the user runs the application a second time, SetWindowPlacement() uses the stored information to restore the state of the windows.

Download MDIREST.EXE, a self-extracting file, from the Microsoft Software Library (MSL) on the following services:

  • Microsoft Download Service (MSDL)

          Dial (206) 936-6735 to connect to MSDL
          Download MDIREST.EXE (size: 27759 bytes) 
    
  • Internet (anonymous FTP)

          ftp ftp.microsoft.com
          Change to the \SOFTLIB\MSLFILES directory
          Get MDIREST.EXE (size: 27759 bytes) 
    


Additional reference words: 3.00 3.10 softlib MDIREST.EXE
KBCategory: kbprg kbfile
KBSubcategory: UsrWndw
Keywords : UsrWndw kbfile kbprg
Version : 3.10
Platform : WINDOWS


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: April 7, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.