FIX: Control Overlaid by 2nd Control Won't Refresh If Moved (74519)



The information in this article applies to:

  • Microsoft Visual Basic Standard Edition for Windows 1.0

This article was previously published under Q74519

SYMPTOMS

Visual Basic version 1.0 for Windows does not support overlapping controls. Having overlapping controls can result in portions of a control not refreshing correctly. If controls are moved over each other, then one or both of the controls may not correctly refresh even when the controls are moved apart. This is known to happen when controls are resized at run time using the Move method or by changing the Height and Width properties as a result of a Form_Resize event. Because controls must be resized one at a time, it is possible that one control will briefly overlap another control during the resize process at run time. The control that was briefly overlapped may not refresh properly. An example of this behavior is given in the More Information section below.

WORKAROUND

This behavior can be improved by performing the Refresh method (CtrlName.Refresh) on every overlapping control at run time, after an overlapped control has been moved or after a form that contains overlapping controls has been resized.

STATUS

This is not a problem with Visual Basic. It is the nature of overlapping controls in Visual Basic version 1.0. This behavior occurs at run time in the Visual Basic development environment or as an .EXE program.

This problem does not occur in Visual Basic version 2.0 or 3.0 for Windows where overlapping controls are supported.

MORE INFORMATION

For more information about Visual Basic and overlapping controls, query in this knowledge base on the following words:

overlapping and controls and Visual and Basic

Steps to Reproduce Problem

  1. From the File menu, choose New Project (ALT, F, P).
  2. Add a picture control (Picture1) to the default form (Form1).
  3. Add a command button (Command1) to Form1.
  4. Add a vertical scroll bar (VScroll1) to Form1.
  5. Using the mouse, double-click Form1 to bring up the code window.
  6. Within the Resize event procedure of Form1, add the following code:
         Sub Form_Resize ()
             Picture1.Move 0, 0, ScaleWidth - VScroll1.Width, _
                           ScaleHeight - Command1.Height
             VScroll1.Move ScaleWidth - VScroll1.Width, 0, _
                           VScroll1.Width, ScaleHeight - Command1.Height
             Command1.Move 0, ScaleHeight - Command1.Height, _
                           ScaleWidth, Command1.Height
         End Sub
    						
Note: The underscores (_) in the above code example indicate that the line should be concatenated with the next line in the Visual Basic environment (VB.EXE).

  1. Run the program.
  2. Using the mouse, resize the form by extending the bottom or right sides. When the bottom edge of the form is extended, the command button (Command1) will not refresh. When the right edge of Form1 is extended, the scroll bar will not refresh. The refresh problems are caused because Picture1 is expanded and temporarily overlaps the control. When the control (VScroll1 or Command1) is moved out of the way, it is not refreshed.
To work around this behavior, use the Refresh method for Picture1, VScroll1, and Command1 after the controls have be moved. Add the following statements to Sub Form_Resize (after the Command1.Move statement) above to overcome the behavior:
   Picture1.Refresh
   VScroll1.Refresh
   Command1.Refresh
				

Modification Type:MinorLast Reviewed:1/9/2003
Keywords:kbbug KB74519