INFO: Overlapping Controls Are Not Supported by Windows

ID: Q79981


The information in this article applies to:
  • Microsoft Windows Software Development Kit (SDK)
  • Microsoft Win32 Software Development Kit (SDK)
  • Microsoft Windows 2000


SUMMARY

Child window controls should not be overlapped in applications for the Windows operating system. When one control overlaps another control, or another child window, Windows may or may not draw the window or some of its elements correctly. This behavior is a consequence of the way that Windows is designed.


MORE INFORMATION

The following example illustrates the painting problems caused by the ambiguity of overlapping borders. Consider three edit controls, called A, B and C, which overlap each other, and an enclosing child window D:


     ____________________________________________
     | | A          | B          | C          | |
     | ---------------------------------------- |
     |                 D                        |
     -------------------------------------------- 
Assume that control B has the focus. If this set of controls is covered by another window, which is subsequently moved away, Windows will send a series of client and nonclient messages to each of the controls and to the enclosing child window. The result of these messages may appear as the illustration below, where the portion of window B's border that overlapped with part of window D's border is missing:

     _______________             ________________
     | | A          | B          | C          | |
     | ---------------------------------------- |
     |                 D                        |
     -------------------------------------------- 
Repainting problems related to overlapping controls may vary depending on the control and version of Windows used. To avoid this problem, ensure that all child windows are not overlapping or that all windows are members of the same child-parent hierarchy. For example:

     ________
                    ________
                   | Parent |
                    --------
                   /        \ 
         _________            _________
        | Child A |          | Child B |
         ---------            ---------
         /        \     
     ________    ________
    | Child C|  | Child D|
     --------    -------- 
In this case, all of the child windows are control windows. Child A and Child B are overlapped sibling windows. Therefore, the all of the child windows may have painting problems. The way to correct this and still have overlapped control windows is to make Child B the parent of Child A (or visa versa).

Another consequence of having overlapping controls is that the user of the application may be confused, because clicking the mouse in the common area may not activate the control that the user intended to activate.

Additional query words:

Keywords : kbCtrl kbDlg kbNTOS kbWinOS2000 kbSDKWin32 kbGrpUser kbWinOS kbWndw kbWndwProp
Version : WINDOWS:
Platform : WINDOWS
Issue type : kbinfo


Last Reviewed: January 27, 2000
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.