Form/Picture Box Background Cleared when AutoRedraw=False
ID: Q92380
|
The information in this article applies to:
-
Microsoft Visual Basic Standard and Professional Editions for MS-DOS, version 1.0
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 "control paint
bleeding." 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, "x")
NEXT x
END SUB
SUB Form_Click()
MSGBOX "abc"
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.
- Choose the OK button in the message box to close it.
- The form now receives a Paint event, and the code in Form_Paint is
executed again and the form background is reprinted.
Additional query words:
VBmsdos 1.00
Keywords :
Version : MS-DOS:1.0
Platform : MS-DOS
Issue type :