Using the DeferWindowPos Family of Functions

Last reviewed: November 2, 1995
Article ID: Q87345
The information in this article applies to:
  • Microsoft Windows Software Development Kit (SDK) versions 3.1
  • Microsoft Win32 Application Programming Interface (API) included with:

        - Microsoft Windows NT versions 3.5 and 3.51
        - Microsoft Windows 95 version 4.0
    

SUMMARY

In the Microsoft Windows graphical environment, an application can use the BeginDeferWindowPos, DeferWindowPos, and EndDeferWindowPos functions when it moves or sizes a set of windows simultaneously. Using these functions avoids unnecessary screen painting, which would occur if the windows were moved individually.

The eighth parameter to the DeferWindowPos function can be any one of eight flag values that affect the size and position of each moved or sized window. One of the flags, SWP_NOREDRAW, disables repainting and prevents Windows from displaying any changes to the screen. This flag effects both the client and nonclient areas of the window. Any portion of its parent window uncovered by the move or size operation must be explicitly invalidated and redrawn.

If the moved or sized windows are child windows or pop-up windows, then the SWP_NOREDRAW flag has the expected effect. However, if the window is an edit control, a combo box control, or a list box control, then specifying SWP_NOREDRAW has no effect; the control is drawn at its new location and its previous location is not erased. This behavior is caused by the manner in which these three control classes are painted. Buttons and static controls function normally.

To work around this limitation and move a group of edit, list box, and combo box controls in a visually pleasing manner, perform the following three steps:

  1. Use the ShowWindow function to hide all of the controls.

  2. Move or size the controls as required with the MoveWindow and SetWindowPos functions.

  3. Use the ShowWindow function to display all of the controls.


Additional reference words: 3.00 3.10 3.50 3.51 4.00 95 combobox listbox
KBCategory: kbui
KBSubcategory: UsrWndw


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: November 2, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.