Microsoft KB Archive/92380

= Form/Picture Box Background Cleared when AutoRedraw=False =

PSS ID Number: 92380

Article Last Modified on 1/9/2003

-

The information in this article applies to:


 * Microsoft Visual Basic for MS-DOS 1.0

-



This article was previously published under Q92380



SUMMARY
Visual Basic for MS-DOS tends to repaint more frequently than its counterpart product, Microsoft Visual Basic for Windows, version 1.0.

The background of forms and picture boxes need to be repainted when the AutoRedraw property is set to False and any of the following occur:


 * The form or picture box is moved.
 * The form or picture box is resized.
 * Another form or picture box is displayed.
 * A message box (MSGBOX) is displayed.
 * An input box (INPUTBOX) is displayed.

The extra paint events are needed to help prevent &quot;control paint bleeding.&quot; Control paint bleeding occurs when a piece of a control or form is visible through another control or form.



MORE INFORMATION
To preserve the image in your form or picture box without having to repaint it, set the AutoRedraw property of the form and/or picture box to True.

Another alternative is to add code to the Form_Paint and/or Picture1_Paint event procedure to redraw all that was on the form and/or picture box. The Paint event for the form and/or picture box will be called in each of the above listed cases, allowing such code to work.

Example
 Start VBDOS.EXE. From the File menu, choose New Form. Exit the Form Designer (FD.EXE) and save all changes.  Add the following code to the appropriate event procedures: SUB Form_Paint CurrentX = 0 CurrentY = 0 FOR x = 1 to 10 PRINT STRING$(45, &quot;x&quot;) NEXT x   END SUB

SUB Form_Click MSGBOX &quot;abc&quot; END SUB  Press F5 to start the program. The field of 'x' is printed. Click on the form. The message box is displayed, and the background of the form is cleared.</li> Choose the OK button in the message box to close it.</li> The form now receives a Paint event, and the code in Form_Paint is executed again and the form background is reprinted.</li></ol>

Additional query words: VBmsdos 1.00

Keywords: KB92380

Technology: kbAudDeveloper kbVB100DOS kbVBSearch kbZNotKeyword3

-

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

© 2004 Microsoft Corporation. All rights reserved.