ID Number: Q74444
3.00
WINDOWS
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.