Microsoft KB Archive/92380

From BetaArchive Wiki
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
Knowledge Base


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 "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

  1. Start VBDOS.EXE.
  2. From the File menu, choose New Form.
  3. Exit the Form Designer (FD.EXE) and save all changes.
  4. 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
                            
  5. Press F5 to start the program.
  6. The field of 'x' is printed.
  7. Click on the form. The message box is displayed, and the background of the form is cleared.
  8. Choose the OK button in the message box to close it.
  9. 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: KB92380
Technology: kbAudDeveloper kbVB100DOS kbVBSearch kbZNotKeyword3