Re: Dialog window won't update display
I have a dialog based MFC application (VS2005) that controls an automation
process. There is a worker thread in the background handling some machine
interfaces. The main thread provides status displays via static text boxes
and UpdateData(FALSE). The worker thread does not write to the window.
Dave,
How does the worker thread communicate the updated data to the main UI
thread (I'm assuming it does somehow)?
Sometimes the window will not update the display.
Any idea what the "sometimes" situation is - is it just time the
application has been running, or perhaps after some other action on
the machine?
The process keeps running,
so I know both threads are working.
Is the worker/gui thread communication working though?
Strangely, if I pop up a standard
MessageBox for operator yes/no input the window will update it's display
after the messagebox closes and continue to update normally from that point
on.
Do you have any timers in your application? Are they perhaps not
occurring when the "sometimes" situation arises? When a messagebox is
displayed, the message processing is done in a separate message
dispatch loop - not the loop in your application. Quite why it has the
effect it does is difficult to guess, but undoubtedly it'll make more
sense when you discover the root of the problem.
Can you reproduce the problem with a debug build, and while debugging?
If you can, a few trace points in the code at strategic places may
shed some light onto the problem.
I've interspersed calls to RedrawWindow() at various points within the main
loop with no apparent improvement.
As you've found, things like that are not going to be the answer -
best to discover what's really going on and solve it properly.
Dave Lowndes