HOWTO: Clear a Message Box

ID: Q74444


The information in this article applies to:
  • Microsoft Win32 Software Development Kit (SDK)
  • Microsoft Windows Software Development Kit (SDK) versions 3.0, 3.1
  • Microsoft Windows 2000


SUMMARY

During the processing of the MessageBox() function, Windows creates a bitmap to save the part of the screen covered by the message box. Normally, before the MessageBox() function returns, Windows repaints the portion of the screen covered by the message box using the bitmap. In this scenario, when the user clicks on a button to dismiss the message box, the message box disappears immediately.

It is important to note that under low memory conditions, Windows will discard the bitmap. If the bitmap is discarded and a significant amount of processing takes place between the MessageBox() call and painting the application's window, the vestigial image of the message box will remain on the screen during the processing. If the user clicks on this image with the mouse, the underlying window will receive the mouse messages. This can cause unexpected (and possibly undesirable) effects.

To address this problem, call UpdateWindow() immediately after MessageBox(). The parameter to UpdateWindow() should be the parent window of the message box (or of the application's main window if the message box has no parent). This will cause the application to paint the affected window if the bitmap has been discarded. The message box will disappear immediately under all circumstances.

Additional query words: WIN16SDK

Keywords : kbMessageBox kbNTOS kbWinOS2000 kbSDKWin32 kbGrpUser kbWinOS
Version : WINDOWS:3.0,3.1
Platform : WINDOWS
Issue type : kbhowto


Last Reviewed: January 28, 2000
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.