We have tested the problem using Prof-UIS sample applications. Most of the sample applications have the following method in the application class for displaying the About dialog box:
void CApp::OnAppAbout()
{
VERIFY( ProfUISAbout() );
}
This method displays the About dialog immediately. To emulate a lengthy operation, we modified the method above in this way:
void CApp::OnAppAbout()
{
Sleep( 3000 ); // THIS EMULATES LENGTHY OPERATION (3 SECONDS)
VERIFY( ProfUISAbout() );
}
We noticed the popup menu disappeared correctly and the content under the hidden popup menu was also painted correctly. But the menu bar’s button was not repainted until the lengthy 3 second operation is completed. To fix the problem we have modified the method again and made all the delayed painting requests to be forcibly handled before the lengthy operation starts:
void CApp::OnAppAbout()
{
CExtPaintManager::stat_PassPaintMessages(); // DELIVER ALL THE DELAYED PAINTING REQUESTS
Sleep( 3000 );
VERIFY( ProfUISAbout() );
}
This is the correct way to avoid unpainted areas of any windows before lengthy operations.
Besides, we must note the following: lengthy operations should be implemented in the background threads to avoid any situations when your application simply does not respond to user input. It is not correct to implement a several seconds lengthy operation in the main UI thread of your application without a progress dialog and an unprocessed message loop.