1

In our application we have an MFC dialog that opens and processes some data needed to display. Hence the processing is initiated lazily inside OnPaint() event. The processing takes some time (about 20-30 sec), and is solely algorithmic (no UI API called). What happens is that sometimes after the processing is finished the window "disappears". We found out that it's brought behind the parent window (main frame).

Calling SetForegroundWindow() right after processing has finished, or performing the processing in a non-UI thread (letting OnPaint() finish in reasonable time) has eliminated the problem.

Is this issue known? Is there any defined time limit for OnPaint() execution?

Thanks,

Alex.

1
  • 1
    You should comment out the processing part and see if the window still disappears to narrow it down.
    – zar
    Mar 5, 2012 at 14:19

1 Answer 1

1

http://msdn.microsoft.com/en-us/library/01c9aaty%28v=vs.80%29.aspx

The WM_PAINT message is sent when the UpdateWindow or RedrawWindow member function is called.

A window may receive internal paint messages as a result of calling the RedrawWindow member function with the RDW_INTERNALPAINT flag set. In this case, the window may not have an update region. An application should call the GetUpdateRect member function to determine whether the window has an update region. If GetUpdateRect returns 0, the application should not call the BeginPaint and EndPaint member functions.

It is an application's responsibility to check for any necessary internal repainting or updating by looking at its internal data structures for each WM_PAINT message because a WM_PAINT message may have been caused by both an invalid area and a call to the RedrawWindow member function with the RDW_INTERNALPAINT flag set.

An internal WM_PAINT message is sent only once by Windows. After an internal WM_PAINT message is sent to a window by the UpdateWindow member function, no further WM_PAINT messages will be sent or posted until the window is invalidated or until the RedrawWindow member function is called again with the RDW_INTERNALPAINT flag set.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.