Microsoft KB Archive/74519

= FIX: Control Overlaid by 2nd Control Won't Refresh If Moved =

Article ID: 74519

Article Last Modified on 1/9/2003

-

APPLIES TO


 * Microsoft Visual Basic 1.0 Standard Edition

-



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
 From the File menu, choose New Project (ALT, F, P). Add a picture control (Picture1) to the default form (Form1). Add a command button (Command1) to Form1. Add a vertical scroll bar (VScroll1) to Form1. Using the mouse, double-click Form1 to bring up the code window.  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 </li></ol>

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

Additional query words: fixlist2.00 fixlist3.00 2.00 3.00

Keywords: kbbug kbfix KB74519

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.